[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/di/extension/ -> core.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\di\extension;
  15  
  16  use Symfony\Component\Config\FileLocator;
  17  use Symfony\Component\Config\Resource\FileResource;
  18  use Symfony\Component\DependencyInjection\ContainerBuilder;
  19  use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  20  use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  21  
  22  /**
  23  * Container core extension
  24  */
  25  class core extends Extension
  26  {
  27      const TWIG_OPTIONS_POSITION = 7;
  28  
  29      /**
  30       * Config path
  31       * @var string
  32       */
  33      protected $config_path;
  34  
  35      /**
  36       * Constructor
  37       *
  38       * @param string $config_path Config path
  39       */
  40  	public function __construct($config_path)
  41      {
  42          $this->config_path = $config_path;
  43      }
  44  
  45      /**
  46       * Loads a specific configuration.
  47       *
  48       * @param array            $configs   An array of configuration values
  49       * @param ContainerBuilder $container A ContainerBuilder instance
  50       *
  51       * @throws \InvalidArgumentException When provided tag is not defined in this extension
  52       */
  53  	public function load(array $configs, ContainerBuilder $container)
  54      {
  55          $filesystem = new \phpbb\filesystem\filesystem();
  56          $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->config_path)));
  57          $loader->load($container->getParameter('core.environment') . '/container/environment.yml');
  58  
  59          $config = $this->getConfiguration($configs, $container);
  60          $config = $this->processConfiguration($config, $configs);
  61  
  62          if ($config['require_dev_dependencies'])
  63          {
  64              if (!class_exists('Goutte\Client', true))
  65              {
  66                  trigger_error(
  67                      'Composer development dependencies have not been set up for the ' . $container->getParameter('core.environment') . ' environment yet, run ' .
  68                      "'php ../composer.phar install --dev' from the phpBB directory to do so.",
  69                      E_USER_ERROR
  70                  );
  71              }
  72          }
  73  
  74          $container->setParameter('allow_install_dir', $config['allow_install_dir']);
  75  
  76          // Set the Twig options if defined in the environment
  77          $definition = $container->getDefinition('template.twig.environment');
  78          $twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION);
  79          if ($config['twig']['debug'])
  80          {
  81              $twig_environment_options['debug'] = true;
  82          }
  83          if ($config['twig']['auto_reload'])
  84          {
  85              $twig_environment_options['auto_reload'] = true;
  86          }
  87  
  88          // Replace the 7th argument, the options passed to the environment
  89          $definition->replaceArgument(static::TWIG_OPTIONS_POSITION, $twig_environment_options);
  90  
  91          if ($config['twig']['enable_debug_extension'])
  92          {
  93              $definition = $container->getDefinition('template.twig.extensions.debug');
  94              $definition->addTag('twig.extension');
  95          }
  96  
  97          // Set the debug options
  98          foreach ($config['debug'] as $name => $value)
  99          {
 100              $container->setParameter('debug.' . $name, $value);
 101          }
 102  
 103          // Set the log options
 104          foreach ($config['session'] as $name => $value)
 105          {
 106              $container->setParameter('session.' . $name, $value);
 107          }
 108      }
 109  
 110      /**
 111       * {@inheritdoc}
 112       */
 113  	public function getConfiguration(array $config, ContainerBuilder $container)
 114      {
 115          $r = new \ReflectionClass('\phpbb\di\extension\container_configuration');
 116          $container->addResource(new FileResource($r->getFileName()));
 117  
 118          return new container_configuration();
 119      }
 120  
 121      /**
 122       * Returns the recommended alias to use in XML.
 123       *
 124       * This alias is also the mandatory prefix to use when using YAML.
 125       *
 126       * @return string The alias
 127       */
 128  	public function getAlias()
 129      {
 130          return 'core';
 131      }
 132  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1