Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Extension.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 3.73 KiB


 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       * Returns the base path for the XSD files.
 031       *
 032       * @return string The XSD base path
 033       */
 034      public function getXsdValidationBasePath()
 035      {
 036          return false;
 037      }
 038   
 039      /**
 040       * Returns the namespace to be used for this extension (XML namespace).
 041       *
 042       * @return string The XML namespace
 043       */
 044      public function getNamespace()
 045      {
 046          return 'http://example.org/schema/dic/'.$this->getAlias();
 047      }
 048   
 049      /**
 050       * Returns the recommended alias to use in XML.
 051       *
 052       * This alias is also the mandatory prefix to use when using YAML.
 053       *
 054       * This convention is to remove the "Extension" postfix from the class
 055       * name and then lowercase and underscore the result. So:
 056       *
 057       *     AcmeHelloExtension
 058       *
 059       * becomes
 060       *
 061       *     acme_hello
 062       *
 063       * This can be overridden in a sub-class to specify the alias manually.
 064       *
 065       * @return string The alias
 066       *
 067       * @throws BadMethodCallException When the extension name does not follow conventions
 068       */
 069      public function getAlias()
 070      {
 071          $className = get_class($this);
 072          if (substr($className, -9) != 'Extension') {
 073              throw new BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
 074          }
 075          $classBaseName = substr(strrchr($className, '\\'), 1, -9);
 076   
 077          return Container::underscore($classBaseName);
 078      }
 079   
 080      /**
 081       * {@inheritdoc}
 082       */
 083      public function getConfiguration(array $config, ContainerBuilder $container)
 084      {
 085          $reflected = new \ReflectionClass($this);
 086          $namespace = $reflected->getNamespaceName();
 087   
 088          $class = $namespace.'\\Configuration';
 089          if (class_exists($class)) {
 090              $r = new \ReflectionClass($class);
 091              $container->addResource(new FileResource($r->getFileName()));
 092   
 093              if (!method_exists($class, '__construct')) {
 094                  $configuration = new $class();
 095   
 096                  return $configuration;
 097              }
 098          }
 099      }
 100   
 101      final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
 102      {
 103          $processor = new Processor();
 104   
 105          return $processor->processConfiguration($configuration, $configs);
 106      }
 107   
 108      /**
 109       * @param ContainerBuilder $container
 110       * @param array            $config
 111       *
 112       * @return bool    Whether the configuration is enabled
 113       *
 114       * @throws InvalidArgumentException When the config is not enableable
 115       */
 116      protected function isConfigEnabled(ContainerBuilder $container, array $config)
 117      {
 118          if (!array_key_exists('enabled', $config)) {
 119              throw new InvalidArgumentException("The config array has no 'enabled' key.");
 120          }
 121   
 122          return (bool) $container->getParameterBag()->resolveValue($config['enabled']);
 123      }
 124  }
 125