|
4 | 4 |
|
5 | 5 | namespace App;
|
6 | 6 |
|
| 7 | +use Nette; |
7 | 8 | use Nette\Bootstrap\Configurator;
|
8 | 9 |
|
9 | 10 |
|
10 | 11 | class Bootstrap
|
11 | 12 | {
|
12 |
| - public static function boot(): Configurator |
| 13 | + private Configurator $configurator; |
| 14 | + private string $rootDir; |
| 15 | + |
| 16 | + |
| 17 | + public function __construct() |
| 18 | + { |
| 19 | + $this->rootDir = dirname(__DIR__); |
| 20 | + $this->configurator = new Configurator; |
| 21 | + $this->configurator->setTempDirectory($this->rootDir . '/temp'); |
| 22 | + } |
| 23 | + |
| 24 | + |
| 25 | + public function bootWebApplication(): Nette\DI\Container |
13 | 26 | {
|
14 |
| - $configurator = new Configurator; |
15 |
| - $rootDir = dirname(__DIR__); |
| 27 | + $this->initializeEnvironment(); |
| 28 | + $this->setupContainer(); |
| 29 | + return $this->configurator->createContainer(); |
| 30 | + } |
16 | 31 |
|
17 |
| - //$configurator->setDebugMode('[email protected]'); // enable for your remote IP |
18 |
| - $configurator->enableTracy($rootDir . '/log'); |
19 | 32 |
|
20 |
| - $configurator->setTempDirectory($rootDir . '/temp'); |
| 33 | + public function initializeEnvironment(): void |
| 34 | + { |
| 35 | + //$this->configurator->setDebugMode('[email protected]'); // enable for your remote IP |
| 36 | + $this->configurator->enableTracy($this->rootDir . '/log'); |
21 | 37 |
|
22 |
| - $configurator->createRobotLoader() |
| 38 | + $this->configurator->createRobotLoader() |
23 | 39 | ->addDirectory(__DIR__)
|
24 | 40 | ->register();
|
| 41 | + } |
25 | 42 |
|
26 |
| - $configurator->addConfig($rootDir . '/config/common.neon'); |
27 |
| - $configurator->addConfig($rootDir . '/config/services.neon'); |
28 | 43 |
|
29 |
| - return $configurator; |
| 44 | + private function setupContainer(): void |
| 45 | + { |
| 46 | + $configDir = $this->rootDir . '/config'; |
| 47 | + $this->configurator->addConfig($configDir . '/common.neon'); |
| 48 | + $this->configurator->addConfig($configDir . '/services.neon'); |
30 | 49 | }
|
31 | 50 | }
|
0 commit comments