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

HttpFoundationExtension.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 4.18 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\Bridge\Twig\Extension;
 013   
 014  use Symfony\Component\HttpFoundation\Request;
 015  use Symfony\Component\HttpFoundation\RequestStack;
 016  use Symfony\Component\Routing\RequestContext;
 017  use Twig\Extension\AbstractExtension;
 018  use Twig\TwigFunction;
 019   
 020  /**
 021   * Twig extension for the Symfony HttpFoundation component.
 022   *
 023   * @author Fabien Potencier <fabien@symfony.com>
 024   */
 025  class HttpFoundationExtension extends AbstractExtension
 026  {
 027      private $requestStack;
 028      private $requestContext;
 029   
 030      public function __construct(RequestStack $requestStack, RequestContext $requestContext = null)
 031      {
 032          $this->requestStack = $requestStack;
 033          $this->requestContext = $requestContext;
 034      }
 035   
 036      /**
 037       * {@inheritdoc}
 038       */
 039      public function getFunctions()
 040      {
 041          return [
 042              new TwigFunction('absolute_url', [$this, 'generateAbsoluteUrl']),
 043              new TwigFunction('relative_path', [$this, 'generateRelativePath']),
 044          ];
 045      }
 046   
 047      /**
 048       * Returns the absolute URL for the given absolute or relative path.
 049       *
 050       * This method returns the path unchanged if no request is available.
 051       *
 052       * @param string $path The path
 053       *
 054       * @return string The absolute URL
 055       *
 056       * @see Request::getUriForPath()
 057       */
 058      public function generateAbsoluteUrl($path)
 059      {
 060          if (false !== strpos($path, '://') || '//' === substr($path, 0, 2)) {
 061              return $path;
 062          }
 063   
 064          if (!$request = $this->requestStack->getMasterRequest()) {
 065              if (null !== $this->requestContext && '' !== $host = $this->requestContext->getHost()) {
 066                  $scheme = $this->requestContext->getScheme();
 067                  $port = '';
 068   
 069                  if ('http' === $scheme && 80 != $this->requestContext->getHttpPort()) {
 070                      $port = ':'.$this->requestContext->getHttpPort();
 071                  } elseif ('https' === $scheme && 443 != $this->requestContext->getHttpsPort()) {
 072                      $port = ':'.$this->requestContext->getHttpsPort();
 073                  }
 074   
 075                  if ('#' === $path[0]) {
 076                      $queryString = $this->requestContext->getQueryString();
 077                      $path = $this->requestContext->getPathInfo().($queryString ? '?'.$queryString : '').$path;
 078                  } elseif ('?' === $path[0]) {
 079                      $path = $this->requestContext->getPathInfo().$path;
 080                  }
 081   
 082                  if ('/' !== $path[0]) {
 083                      $path = rtrim($this->requestContext->getBaseUrl(), '/').'/'.$path;
 084                  }
 085   
 086                  return $scheme.'://'.$host.$port.$path;
 087              }
 088   
 089              return $path;
 090          }
 091   
 092          if ('#' === $path[0]) {
 093              $path = $request->getRequestUri().$path;
 094          } elseif ('?' === $path[0]) {
 095              $path = $request->getPathInfo().$path;
 096          }
 097   
 098          if (!$path || '/' !== $path[0]) {
 099              $prefix = $request->getPathInfo();
 100              $last = \strlen($prefix) - 1;
 101              if ($last !== $pos = strrpos($prefix, '/')) {
 102                  $prefix = substr($prefix, 0, $pos).'/';
 103              }
 104   
 105              return $request->getUriForPath($prefix.$path);
 106          }
 107   
 108          return $request->getSchemeAndHttpHost().$path;
 109      }
 110   
 111      /**
 112       * Returns a relative path based on the current Request.
 113       *
 114       * This method returns the path unchanged if no request is available.
 115       *
 116       * @param string $path The path
 117       *
 118       * @return string The relative path
 119       *
 120       * @see Request::getRelativeUriForPath()
 121       */
 122      public function generateRelativePath($path)
 123      {
 124          if (false !== strpos($path, '://') || '//' === substr($path, 0, 2)) {
 125              return $path;
 126          }
 127   
 128          if (!$request = $this->requestStack->getMasterRequest()) {
 129              return $path;
 130          }
 131   
 132          return $request->getRelativeUriForPath($path);
 133      }
 134   
 135      /**
 136       * Returns the name of the extension.
 137       *
 138       * @return string The extension name
 139       */
 140      public function getName()
 141      {
 142          return 'request';
 143      }
 144  }
 145