vendor/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php
equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony framework. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * This source file is subject to the MIT license that is bundled |
|
9 * with this source code in the file LICENSE. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Component\HttpKernel\DependencyInjection; |
|
13 |
|
14 use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
15 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
16 use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
17 use Symfony\Component\HttpKernel\Kernel; |
|
18 |
|
19 /** |
|
20 * Sets the classes to compile in the cache for the container. |
|
21 * |
|
22 * @author Fabien Potencier <fabien@symfony.com> |
|
23 */ |
|
24 class AddClassesToCachePass implements CompilerPassInterface |
|
25 { |
|
26 private $kernel; |
|
27 |
|
28 public function __construct(Kernel $kernel) |
|
29 { |
|
30 $this->kernel = $kernel; |
|
31 } |
|
32 |
|
33 /** |
|
34 * {@inheritDoc} |
|
35 */ |
|
36 public function process(ContainerBuilder $container) |
|
37 { |
|
38 $classes = array(); |
|
39 foreach ($container->getExtensions() as $extension) { |
|
40 if ($extension instanceof Extension) { |
|
41 $classes = array_merge($classes, $extension->getClassesToCompile()); |
|
42 } |
|
43 } |
|
44 |
|
45 $this->kernel->setClassCache(array_unique($container->getParameterBag()->resolveValue($classes))); |
|
46 } |
|
47 } |