Skip to content

Commit

Permalink
fix(container): autowires does't work
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel00per committed Feb 5, 2024
1 parent 0f208cb commit 03edd50
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/DependencyInjection/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ public static function create(array|string $settings): ContainerInterface
$autoWiresDefinitions = File::require($autoWiresPath, 'Auto wires file does not exist');

// 2. Crete container
$isAutoWiringEnabled = $settingsArray['di']['auto_wires']['enabled'];
$containerBuilder = ContainerBuilder::create()
->addSettingsArray($settingsArray)
->addRootPath($settingsArray['rootPath'])
->addRootNamespace($settingsArray['rootNamespace'])
->useAutoWiring($settingsArray['di']['auto_wires']['enabled'])
->useAutoWiring($isAutoWiringEnabled)
->useAttributes($settingsArray['di']['attributes']['enabled'])
;

if ($isAutoWiringEnabled) {
$containerBuilder->addDefinitions($autoWiresDefinitions);
}

// 3. Cache
if (Environment::from($settingsArray['environment']) === Environment::PRODUCTION) {
$containerCachePath = $settingsArray['di']['cache']['container']['path'];
Expand All @@ -48,7 +53,7 @@ public static function create(array|string $settings): ContainerInterface
$containerBuilder
->enableCompilation($containerCachePath)
->addResolverCachePathFile($resolverCachePathFile)
->addDefinitions($autoWiresDefinitions);
;
}

// 4. Add definitions
Expand Down

0 comments on commit 03edd50

Please sign in to comment.