Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
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\DependencyInjection\Container;
015 use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
016 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
017 use Symfony\Component\Config\Resource\FileResource;
018 use Symfony\Component\DependencyInjection\ContainerBuilder;
019 use Symfony\Component\Config\Definition\Processor;
020 use Symfony\Component\Config\Definition\ConfigurationInterface;
021
022 /**
023 * Provides useful features shared by many extensions.
024 *
025 * @author Fabien Potencier <fabien@symfony.com>
026 */
027 abstract class Extension implements ExtensionInterface, ConfigurationExtensionInterface
028 {
029 /**
030 * {@inheritdoc}
031 */
032 public function getXsdValidationBasePath()
033 {
034 return false;
035 }
036
037 /**
038 * {@inheritdoc}
039 */
040 public function getNamespace()
041 {
042 return 'http://example.org/schema/dic/'.$this->getAlias();
043 }
044
045 /**
046 * Returns the recommended alias to use in XML.
047 *
048 * This alias is also the mandatory prefix to use when using YAML.
049 *
050 * This convention is to remove the "Extension" postfix from the class
051 * name and then lowercase and underscore the result. So:
052 *
053 * AcmeHelloExtension
054 *
055 * becomes
056 *
057 * acme_hello
058 *
059 * This can be overridden in a sub-class to specify the alias manually.
060 *
061 * @return string The alias
062 *
063 * @throws BadMethodCallException When the extension name does not follow conventions
064 */
065 public function getAlias()
066 {
067 $className = get_class($this);
068 if (substr($className, -9) != 'Extension') {
069 throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
070 }
071 $classBaseName = substr(strrchr($className, '\\'), 1, -9);
072
073 return Container::underscore($classBaseName);
074 }
075
076 /**
077 * {@inheritdoc}
078 */
079 public function getConfiguration(array $config, ContainerBuilder $container)
080 {
081 $reflected = new \ReflectionClass($this);
082 $namespace = $reflected->getNamespaceName();
083
084 $class = $namespace.'\\Configuration';
085 if (class_exists($class)) {
086 $r = new \ReflectionClass($class);
087 $container->addResource(new FileResource($r->getFileName()));
088
089 if (!method_exists($class, '__construct')) {
090 return new $class();
091 }
092 }
093 }
094
095 final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
096 {
097 $processor = new Processor();
098
099 return $processor->processConfiguration($configuration, $configs);
100 }
101
102 /**
103 * @param ContainerBuilder $container
104 * @param array $config
105 *
106 * @return bool Whether the configuration is enabled
107 *
108 * @throws InvalidArgumentException When the config is not enableable
109 */
110 protected function isConfigEnabled(ContainerBuilder $container, array $config)
111 {
112 if (!array_key_exists('enabled', $config)) {
113 throw new InvalidArgumentException("The config array has no 'enabled' key.");
114 }
115
116 return (bool) $container->getParameterBag()->resolveValue($config['enabled']);
117 }
118 }
119