[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Compiler/ -> MergeExtensionConfigurationPass.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\DependencyInjection\Compiler;
  13  
  14  use Symfony\Component\DependencyInjection\ContainerBuilder;
  15  use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
  16  use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
  17  
  18  /**
  19   * Merges extension configs into the container builder.
  20   *
  21   * @author Fabien Potencier <fabien@symfony.com>
  22   */
  23  class MergeExtensionConfigurationPass implements CompilerPassInterface
  24  {
  25      /**
  26       * {@inheritdoc}
  27       */
  28      public function process(ContainerBuilder $container)
  29      {
  30          $parameters = $container->getParameterBag()->all();
  31          $definitions = $container->getDefinitions();
  32          $aliases = $container->getAliases();
  33          $exprLangProviders = $container->getExpressionLanguageProviders();
  34  
  35          foreach ($container->getExtensions() as $extension) {
  36              if ($extension instanceof PrependExtensionInterface) {
  37                  $extension->prepend($container);
  38              }
  39          }
  40  
  41          foreach ($container->getExtensions() as $name => $extension) {
  42              if (!$config = $container->getExtensionConfig($name)) {
  43                  // this extension was not called
  44                  continue;
  45              }
  46              $config = $container->getParameterBag()->resolveValue($config);
  47  
  48              $tmpContainer = new ContainerBuilder($container->getParameterBag());
  49              $tmpContainer->setResourceTracking($container->isTrackingResources());
  50              $tmpContainer->addObjectResource($extension);
  51              if ($extension instanceof ConfigurationExtensionInterface && null !== $configuration = $extension->getConfiguration($config, $tmpContainer)) {
  52                  $tmpContainer->addObjectResource($configuration);
  53              }
  54  
  55              foreach ($exprLangProviders as $provider) {
  56                  $tmpContainer->addExpressionLanguageProvider($provider);
  57              }
  58  
  59              $extension->load($config, $tmpContainer);
  60  
  61              $container->merge($tmpContainer);
  62              $container->getParameterBag()->add($parameters);
  63          }
  64  
  65          $container->addDefinitions($definitions);
  66          $container->addAliases($aliases);
  67      }
  68  }


Generated: Tue Apr 7 19:42:26 2020 Cross-referenced by PHPXref 0.7.1