|
4 | 4 |
|
5 | 5 | namespace App; |
6 | 6 |
|
| 7 | +use Nette; |
7 | 8 | use Nette\Bootstrap\Configurator; |
8 | 9 |
|
9 | 10 |
|
|
12 | 13 | */ |
13 | 14 | class Bootstrap |
14 | 15 | { |
15 | | - public static function boot(): Configurator |
| 16 | + private Configurator $configurator; |
| 17 | + private string $rootDir; |
| 18 | + |
| 19 | + |
| 20 | + public function __construct() |
16 | 21 | { |
| 22 | + $this->rootDir = dirname(__DIR__); |
| 23 | + |
17 | 24 | // The configurator is responsible for setting up the application environment and services. |
18 | 25 | // Learn more at https://doc.nette.org/en/bootstrap |
19 | | - $configurator = new Configurator; |
20 | | - $appDir = dirname(__DIR__); |
| 26 | + $this->configurator = new Configurator; |
| 27 | + |
| 28 | + // Set the directory for temporary files generated by Nette (e.g. compiled templates) |
| 29 | + $this->configurator->setTempDirectory($this->rootDir . '/temp'); |
| 30 | + } |
| 31 | + |
| 32 | + |
| 33 | + public function bootWebApplication(): Nette\DI\Container |
| 34 | + { |
| 35 | + $this->initializeEnvironment(); |
| 36 | + $this->setupContainer(); |
| 37 | + return $this->configurator->createContainer(); |
| 38 | + } |
21 | 39 |
|
| 40 | + |
| 41 | + public function initializeEnvironment(): void |
| 42 | + { |
22 | 43 | // Nette is smart, and the development mode turns on automatically, |
23 | 44 | // or you can enable for a specific IP address it by uncommenting the following line: |
24 | | - // $configurator->setDebugMode('[email protected]'); |
| 45 | + // $this->configurator->setDebugMode('[email protected]'); |
25 | 46 |
|
26 | 47 | // Enables Tracy: the ultimate "swiss army knife" debugging tool. |
27 | 48 | // Learn more about Tracy at https://tracy.nette.org |
28 | | - $configurator->enableTracy($appDir . '/log'); |
29 | | - |
30 | | - // Set the directory for temporary files generated by Nette (e.g. compiled templates) |
31 | | - $configurator->setTempDirectory($appDir . '/temp'); |
| 49 | + $this->configurator->enableTracy($this->rootDir . '/log'); |
| 50 | + } |
32 | 51 |
|
33 | | - // Add configuration files |
34 | | - $configurator->addConfig($appDir . '/config/common.neon'); |
35 | | - $configurator->addConfig($appDir . '/config/services.neon'); |
36 | 52 |
|
37 | | - return $configurator; |
| 53 | + private function setupContainer(): void |
| 54 | + { |
| 55 | + // Load configuration files |
| 56 | + $configDir = $this->rootDir . '/config'; |
| 57 | + $this->configurator->addConfig($configDir . '/common.neon'); |
| 58 | + $this->configurator->addConfig($configDir . '/services.neon'); |
38 | 59 | } |
39 | 60 | } |
0 commit comments