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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

extension_base.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 3.52 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\extension\di;
015   
016  use Symfony\Component\Config\FileLocator;
017  use Symfony\Component\Config\Resource\FileResource;
018  use Symfony\Component\DependencyInjection\ContainerBuilder;
019  use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
020  use Symfony\Component\HttpKernel\DependencyInjection\Extension;
021   
022  /**
023   * Container core extension
024   */
025  class extension_base extends Extension
026  {
027      /**
028       * Name of the extension (vendor/name)
029       *
030       * @var string
031       */
032      protected $extension_name;
033   
034      /**
035       * Path to the extension.
036       *
037       * @var string
038       */
039      protected $ext_path;
040   
041      /**
042       * Constructor
043       *
044       * @param string $extension_name Name of the extension (vendor/name)
045       * @param string $ext_path       Path to the extension
046       */
047      public function __construct($extension_name, $ext_path)
048      {
049          $this->extension_name = $extension_name;
050          $this->ext_path = $ext_path;
051      }
052   
053      /**
054       * Loads a specific configuration.
055       *
056       * @param array            $configs   An array of configuration values
057       * @param ContainerBuilder $container A ContainerBuilder instance
058       *
059       * @throws \InvalidArgumentException When provided tag is not defined in this extension
060       */
061      public function load(array $configs, ContainerBuilder $container)
062      {
063          $this->load_services($container);
064      }
065   
066      /**
067       * Loads the services.yml file.
068       *
069       * @param ContainerBuilder $container A ContainerBuilder instance
070       */
071      protected function load_services(ContainerBuilder $container)
072      {
073          $services_directory = false;
074          $services_file = false;
075   
076          if (file_exists($this->ext_path . 'config/' . $container->getParameter('core.environment') . '/container/environment.yml'))
077          {
078              $services_directory = $this->ext_path . 'config/' . $container->getParameter('core.environment') . '/container/';
079              $services_file = 'environment.yml';
080          }
081          else if (!is_dir($this->ext_path . 'config/' . $container->getParameter('core.environment')))
082          {
083              if (file_exists($this->ext_path . 'config/default/container/environment.yml'))
084              {
085                  $services_directory = $this->ext_path . 'config/default/container/';
086                  $services_file = 'environment.yml';
087              }
088              else if (!is_dir($this->ext_path . 'config/default') && file_exists($this->ext_path . '/config/services.yml'))
089              {
090                  $services_directory = $this->ext_path . 'config';
091                  $services_file = 'services.yml';
092              }
093          }
094   
095          if ($services_directory && $services_file)
096          {
097              $filesystem = new \phpbb\filesystem\filesystem();
098              $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($services_directory)));
099              $loader->load($services_file);
100          }
101      }
102   
103      /**
104       * {@inheritdoc}
105       */
106      public function getConfiguration(array $config, ContainerBuilder $container)
107      {
108          $reflected = new \ReflectionClass($this);
109          $namespace = $reflected->getNamespaceName();
110   
111          $class = $namespace . '\\di\configuration';
112          if (class_exists($class))
113          {
114              $r = new \ReflectionClass($class);
115              $container->addResource(new FileResource($r->getFileName()));
116   
117              if (!method_exists($class, '__construct'))
118              {
119                  $configuration = new $class();
120   
121                  return $configuration;
122              }
123          }
124   
125      }
126   
127      /**
128       * Returns the recommended alias to use in XML.
129       *
130       * This alias is also the mandatory prefix to use when using YAML.
131       *
132       * @return string The alias
133       */
134      public function getAlias()
135      {
136          return str_replace('/', '_', $this->extension_name);
137      }
138  }
139