MergeExtensionConfigurationPass.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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\Compiler\MergeExtensionConfigurationPass as BaseMergeExtensionConfigurationPass;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. /**
  14. * Ensures certain extensions are always loaded.
  15. *
  16. * @author Kris Wallsmith <kris@symfony.com>
  17. */
  18. class MergeExtensionConfigurationPass extends BaseMergeExtensionConfigurationPass
  19. {
  20. private $extensions;
  21. /**
  22. * @param string[] $extensions
  23. */
  24. public function __construct(array $extensions)
  25. {
  26. $this->extensions = $extensions;
  27. }
  28. public function process(ContainerBuilder $container)
  29. {
  30. foreach ($this->extensions as $extension) {
  31. if (!\count($container->getExtensionConfig($extension))) {
  32. $container->loadFromExtension($extension, []);
  33. }
  34. }
  35. parent::process($container);
  36. }
  37. }