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

RedirectResponse.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 2.56 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\HttpFoundation;
013   
014  /**
015   * RedirectResponse represents an HTTP response doing a redirect.
016   *
017   * @author Fabien Potencier <fabien@symfony.com>
018   */
019  class RedirectResponse extends Response
020  {
021      protected $targetUrl;
022   
023      /**
024       * Creates a redirect response so that it conforms to the rules defined for a redirect status code.
025       *
026       * @param string $url     The URL to redirect to. The URL should be a full URL, with schema etc.,
027       *                        but practically every browser redirects on paths only as well
028       * @param int    $status  The status code (302 by default)
029       * @param array  $headers The headers (Location is always set to the given URL)
030       *
031       * @throws \InvalidArgumentException
032       *
033       * @see http://tools.ietf.org/html/rfc2616#section-10.3
034       */
035      public function __construct($url, $status = 302, $headers = array())
036      {
037          parent::__construct('', $status, $headers);
038   
039          $this->setTargetUrl($url);
040   
041          if (!$this->isRedirect()) {
042              throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
043          }
044      }
045   
046      /**
047       * {@inheritdoc}
048       */
049      public static function create($url = '', $status = 302, $headers = array())
050      {
051          return new static($url, $status, $headers);
052      }
053   
054      /**
055       * Returns the target URL.
056       *
057       * @return string target URL
058       */
059      public function getTargetUrl()
060      {
061          return $this->targetUrl;
062      }
063   
064      /**
065       * Sets the redirect target of this response.
066       *
067       * @param string $url The URL to redirect to
068       *
069       * @return RedirectResponse The current response
070       *
071       * @throws \InvalidArgumentException
072       */
073      public function setTargetUrl($url)
074      {
075          if (empty($url)) {
076              throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
077          }
078   
079          $this->targetUrl = $url;
080   
081          $this->setContent(
082              sprintf('<!DOCTYPE html>
083  <html>
084      <head>
085          <meta charset="UTF-8" />
086          <meta http-equiv="refresh" content="1;url=%1$s" />
087   
088          <title>Redirecting to %1$s</title>
089      </head>
090      <body>
091          Redirecting to <a href="%1$s">%1$s</a>.
092      </body>
093  </html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')));
094   
095          $this->headers->set('Location', $url);
096   
097          return $this;
098      }
099  }
100