[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
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 // Set the Twig options if defined in the environment 75 $definition = $container->getDefinition('template.twig.environment'); 76 $twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION); 77 if ($config['twig']['debug']) 78 { 79 $twig_environment_options['debug'] = true; 80 } 81 if ($config['twig']['auto_reload']) 82 { 83 $twig_environment_options['auto_reload'] = true; 84 } 85 86 // Replace the 7th argument, the options passed to the environment 87 $definition->replaceArgument(static::TWIG_OPTIONS_POSITION, $twig_environment_options); 88 89 if ($config['twig']['enable_debug_extension']) 90 { 91 $definition = $container->getDefinition('template.twig.extensions.debug'); 92 $definition->addTag('twig.extension'); 93 } 94 95 // Set the debug options 96 foreach ($config['debug'] as $name => $value) 97 { 98 $container->setParameter('debug.' . $name, $value); 99 } 100 } 101 102 /** 103 * {@inheritdoc} 104 */ 105 public function getConfiguration(array $config, ContainerBuilder $container) 106 { 107 $r = new \ReflectionClass('\phpbb\di\extension\container_configuration'); 108 $container->addResource(new FileResource($r->getFileName())); 109 110 return new container_configuration(); 111 } 112 113 /** 114 * Returns the recommended alias to use in XML. 115 * 116 * This alias is also the mandatory prefix to use when using YAML. 117 * 118 * @return string The alias 119 */ 120 public function getAlias() 121 { 122 return 'core'; 123 } 124 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |