Skip to content

Commit 9da561c

Browse files
committed
Рефакторинг
1 parent ea6ff8c commit 9da561c

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

lib/DI/services.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public function load() : void
129129
return;
130130
}
131131

132+
$this->createContainer();
132133
$compilerContainer = new CompilerContainer();
133134

134135
// Кэшировать контейнер?
@@ -155,13 +156,6 @@ public function load() : void
155156
*/
156157
public function initContainer() : void
157158
{
158-
static::$container = new ContainerBuilder();
159-
$adapter = new BitrixSettingsDiAdapter();
160-
161-
$adapter->importParameters(static::$container, $this->config);
162-
$adapter->importParameters(static::$container, $this->parameters);
163-
$adapter->importServices(static::$container, $this->services);
164-
165159
static::$container->setParameter('kernel.debug', $_ENV['DEBUG'] ?? true);
166160
$loader = new YamlFileLoader(static::$container, new FileLocator(__DIR__ . '/../../configs'));
167161
$loader->load('services.yml');
@@ -266,6 +260,21 @@ public function getContainer(): Container
266260
return static::$container;
267261
}
268262

263+
/**
264+
* Создать пустой экземпляр контейнера.
265+
*
266+
* @return void
267+
*/
268+
private function createContainer() : void
269+
{
270+
static::$container = new ContainerBuilder();
271+
$adapter = new BitrixSettingsDiAdapter();
272+
273+
$adapter->importParameters(static::$container, $this->config);
274+
$adapter->importParameters(static::$container, $this->parameters);
275+
$adapter->importServices(static::$container, $this->services);
276+
}
277+
269278
/**
270279
* @param ContainerBuilder $container
271280
* @param string $defaultClient

0 commit comments

Comments
 (0)