[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/di/extension/ -> config.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\DependencyInjection\ContainerBuilder;
  17  use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  18  
  19  /**
  20  * Container config extension
  21  */
  22  class config extends Extension
  23  {
  24      /** @var array */
  25      protected $config_php;
  26  
  27  	public function __construct(\phpbb\config_php_file $config_php)
  28      {
  29          $this->config_php = $config_php;
  30      }
  31  
  32      /**
  33      * Loads a specific configuration.
  34      *
  35      * @param array            $config    An array of configuration values
  36      * @param ContainerBuilder $container A ContainerBuilder instance
  37      *
  38      * @throws \InvalidArgumentException When provided tag is not defined in this extension
  39      */
  40  	public function load(array $config, ContainerBuilder $container)
  41      {
  42          $parameters = array(
  43              'core.adm_relative_path'    => $this->config_php->get('phpbb_adm_relative_path') ? $this->config_php->get('phpbb_adm_relative_path') : 'adm/',
  44              'core.table_prefix'            => $this->config_php->get('table_prefix'),
  45              'cache.driver.class'        => $this->convert_30_acm_type($this->config_php->get('acm_type')),
  46              'dbal.new_link'                => defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK,
  47          );
  48          $parameter_bag = $container->getParameterBag();
  49  
  50          foreach ($parameters as $parameter => $value)
  51          {
  52              $container->setParameter($parameter, $parameter_bag->escapeValue($value));
  53          }
  54      }
  55  
  56      /**
  57      * Returns the recommended alias to use in XML.
  58      *
  59      * This alias is also the mandatory prefix to use when using YAML.
  60      *
  61      * @return string The alias
  62      */
  63  	public function getAlias()
  64      {
  65          return 'config';
  66      }
  67  
  68      /**
  69      * Convert 3.0 ACM type to 3.1 cache driver class name
  70      *
  71      * @param string $acm_type ACM type
  72      * @return string cache driver class
  73      */
  74  	protected function convert_30_acm_type($acm_type)
  75      {
  76          if (preg_match('#^[a-z]+$#', $acm_type))
  77          {
  78              return 'phpbb\\cache\\driver\\' . $acm_type;
  79          }
  80  
  81          return $acm_type;
  82      }
  83  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1