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

RedirectResponse.php

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