Total Complexity | 4 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class SymfonyCacheExtension extends Extension |
||
14 | { |
||
15 | |||
16 | /* |
||
17 | * id => [ |
||
18 | * class => '', |
||
19 | * args => [] |
||
20 | * ] |
||
21 | */ |
||
22 | |||
23 | public function registerServices(ContainerLoader $container): void |
||
24 | { |
||
25 | $setKernelCache = !$container->has('kernel.cache'); |
||
26 | /** @var array<string, Definition> $definitions */ |
||
27 | $definitions = []; |
||
28 | foreach ($this->config as $id => $adapterConfig) { |
||
29 | $definitions[$id] = new ClassDefinition($adapterConfig['class'], $adapterConfig['args'] ?? []); |
||
30 | if ($setKernelCache) { |
||
31 | $definitions['kernel.cache'] = new AliasDefinition(CacheInterface::class, '@' . $id); |
||
32 | $setKernelCache = false; |
||
33 | } |
||
34 | } |
||
35 | $container->addDefinitions($definitions); |
||
36 | } |
||
37 | |||
38 | public function registerCommands(CommandsLoader $commandLoader): void |
||
42 | } |
||
43 | |||
44 | } |