Drupal investigation

AddClassesToCachePass.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\HttpKernel\Kernel;
  14. /**
  15. * Sets the classes to compile in the cache for the container.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. class AddClassesToCachePass implements CompilerPassInterface
  20. {
  21. private $kernel;
  22. public function __construct(Kernel $kernel)
  23. {
  24. $this->kernel = $kernel;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function process(ContainerBuilder $container)
  30. {
  31. $classes = array();
  32. foreach ($container->getExtensions() as $extension) {
  33. if ($extension instanceof Extension) {
  34. $classes = array_merge($classes, $extension->getClassesToCompile());
  35. }
  36. }
  37. $this->kernel->setClassCache(array_unique($container->getParameterBag()->resolveValue($classes)));
  38. }
  39. }