Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Extension.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\DependencyInjection\Extension;
013
014 use Symfony\Component\Config\Definition\ConfigurationInterface;
015 use Symfony\Component\Config\Definition\Processor;
016 use Symfony\Component\DependencyInjection\Container;
017 use Symfony\Component\DependencyInjection\ContainerBuilder;
018 use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
019 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
020
021 /**
022 * Provides useful features shared by many extensions.
023 *
024 * @author Fabien Potencier <fabien@symfony.com>
025 */
026 abstract class Extension implements ExtensionInterface, ConfigurationExtensionInterface
027 {
028 private $processedConfigs = [];
029
030 /**
031 * {@inheritdoc}
032 */
033 public function getXsdValidationBasePath()
034 {
035 return false;
036 }
037
038 /**
039 * {@inheritdoc}
040 */
041 public function getNamespace()
042 {
043 return 'http://example.org/schema/dic/'.$this->getAlias();
044 }
045
046 /**
047 * Returns the recommended alias to use in XML.
048 *
049 * This alias is also the mandatory prefix to use when using YAML.
050 *
051 * This convention is to remove the "Extension" postfix from the class
052 * name and then lowercase and underscore the result. So:
053 *
054 * AcmeHelloExtension
055 *
056 * becomes
057 *
058 * acme_hello
059 *
060 * This can be overridden in a sub-class to specify the alias manually.
061 *
062 * @return string The alias
063 *
064 * @throws BadMethodCallException When the extension name does not follow conventions
065 */
066 public function getAlias()
067 {
068 $className = static::class;
069 if ('Extension' != substr($className, -9)) {
070 throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
071 }
072 $classBaseName = substr(strrchr($className, '\\'), 1, -9);
073
074 return Container::underscore($classBaseName);
075 }
076
077 /**
078 * {@inheritdoc}
079 */
080 public function getConfiguration(array $config, ContainerBuilder $container)
081 {
082 $class = static::class;
083
084 if (false !== strpos($class, "\0")) {
085 return null; // ignore anonymous classes
086 }
087
088 $class = substr_replace($class, '\Configuration', strrpos($class, '\\'));
089 $class = $container->getReflectionClass($class);
090 $constructor = $class ? $class->getConstructor() : null;
091
092 return $class && (!$constructor || !$constructor->getNumberOfRequiredParameters()) ? $class->newInstance() : null;
093 }
094
095 /**
096 * @return array
097 */
098 final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
099 {
100 $processor = new Processor();
101
102 return $this->processedConfigs[] = $processor->processConfiguration($configuration, $configs);
103 }
104
105 /**
106 * @internal
107 */
108 final public function getProcessedConfigs()
109 {
110 try {
111 return $this->processedConfigs;
112 } finally {
113 $this->processedConfigs = [];
114 }
115 }
116
117 /**
118 * @return bool Whether the configuration is enabled
119 *
120 * @throws InvalidArgumentException When the config is not enableable
121 */
122 protected function isConfigEnabled(ContainerBuilder $container, array $config)
123 {
124 if (!\array_key_exists('enabled', $config)) {
125 throw new InvalidArgumentException("The config array has no 'enabled' key.");
126 }
127
128 return (bool) $container->getParameterBag()->resolveValue($config['enabled']);
129 }
130 }
131