Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

PhpGeneratorDumper.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.47 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\Routing\Generator\Dumper;
 013   
 014  /**
 015   * PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes.
 016   *
 017   * @author Fabien Potencier <fabien@symfony.com>
 018   * @author Tobias Schultze <http://tobion.de>
 019   */
 020  class PhpGeneratorDumper extends GeneratorDumper
 021  {
 022      /**
 023       * Dumps a set of routes to a PHP class.
 024       *
 025       * Available options:
 026       *
 027       *  * class:      The class name
 028       *  * base_class: The base class name
 029       *
 030       * @param array $options An array of options
 031       *
 032       * @return string A PHP class representing the generator class
 033       */
 034      public function dump(array $options = [])
 035      {
 036          $options = array_merge([
 037              'class' => 'ProjectUrlGenerator',
 038              'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
 039          ], $options);
 040   
 041          return <<<EOF
 042  <?php
 043   
 044  use Symfony\Component\Routing\RequestContext;
 045  use Symfony\Component\Routing\Exception\RouteNotFoundException;
 046  use Psr\Log\LoggerInterface;
 047   
 048  /**
 049   * This class has been auto-generated
 050   * by the Symfony Routing Component.
 051   */
 052  class {$options['class']} extends {$options['base_class']}
 053  {
 054      private static \$declaredRoutes;
 055   
 056      public function __construct(RequestContext \$context, LoggerInterface \$logger = null)
 057      {
 058          \$this->context = \$context;
 059          \$this->logger = \$logger;
 060          if (null === self::\$declaredRoutes) {
 061              self::\$declaredRoutes = {$this->generateDeclaredRoutes()};
 062          }
 063      }
 064   
 065  {$this->generateGenerateMethod()}
 066  }
 067   
 068  EOF;
 069   
 070      }
 071   
 072      /**
 073       * Generates PHP code representing an array of defined routes
 074       * together with the routes properties (e.g. requirements).
 075       *
 076       * @return string PHP code
 077       */
 078      private function generateDeclaredRoutes()
 079      {
 080          $routes = "[\n";
 081          foreach ($this->getRoutes()->all() as $name => $route) {
 082              $compiledRoute = $route->compile();
 083   
 084              $properties = [];
 085              $properties[] = $compiledRoute->getVariables();
 086              $properties[] = $route->getDefaults();
 087              $properties[] = $route->getRequirements();
 088              $properties[] = $compiledRoute->getTokens();
 089              $properties[] = $compiledRoute->getHostTokens();
 090              $properties[] = $route->getSchemes();
 091   
 092              $routes .= sprintf("        '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true)));
 093          }
 094          $routes .= '    ]';
 095   
 096          return $routes;
 097      }
 098   
 099      /**
 100       * Generates PHP code representing the `generate` method that implements the UrlGeneratorInterface.
 101       *
 102       * @return string PHP code
 103       */
 104      private function generateGenerateMethod()
 105      {
 106          return <<<'EOF'
 107      public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
 108      {
 109          if (!isset(self::$declaredRoutes[$name])) {
 110              throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
 111          }
 112   
 113          list($variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes) = self::$declaredRoutes[$name];
 114   
 115          return $this->doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
 116      }
 117  EOF;
 118   
 119      }
 120  }
 121