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

RequestContext.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 6.90 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;
 013   
 014  use Symfony\Component\HttpFoundation\Request;
 015   
 016  /**
 017   * Holds information about the current request.
 018   *
 019   * @author Fabien Potencier <fabien@symfony.com>
 020   * @author Tobias Schultze <http://tobion.de>
 021   *
 022   * @api
 023   */
 024  class RequestContext
 025  {
 026      private $baseUrl;
 027      private $pathInfo;
 028      private $method;
 029      private $host;
 030      private $scheme;
 031      private $httpPort;
 032      private $httpsPort;
 033      private $queryString;
 034   
 035      /**
 036       * @var array
 037       */
 038      private $parameters = array();
 039   
 040      /**
 041       * Constructor.
 042       *
 043       * @param string  $baseUrl      The base URL
 044       * @param string  $method       The HTTP method
 045       * @param string  $host         The HTTP host name
 046       * @param string  $scheme       The HTTP scheme
 047       * @param int     $httpPort     The HTTP port
 048       * @param int     $httpsPort    The HTTPS port
 049       * @param string  $path         The path
 050       * @param string  $queryString  The query string
 051       *
 052       * @api
 053       */
 054      public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '')
 055      {
 056          $this->setBaseUrl($baseUrl);
 057          $this->setMethod($method);
 058          $this->setHost($host);
 059          $this->setScheme($scheme);
 060          $this->setHttpPort($httpPort);
 061          $this->setHttpsPort($httpsPort);
 062          $this->setPathInfo($path);
 063          $this->setQueryString($queryString);
 064      }
 065   
 066      /**
 067       * Updates the RequestContext information based on a HttpFoundation Request.
 068       *
 069       * @param Request $request A Request instance
 070       */
 071      public function fromRequest(Request $request)
 072      {
 073          $this->setBaseUrl($request->getBaseUrl());
 074          $this->setPathInfo($request->getPathInfo());
 075          $this->setMethod($request->getMethod());
 076          $this->setHost($request->getHost());
 077          $this->setScheme($request->getScheme());
 078          $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort());
 079          $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort);
 080          $this->setQueryString($request->server->get('QUERY_STRING', ''));
 081      }
 082   
 083      /**
 084       * Gets the base URL.
 085       *
 086       * @return string The base URL
 087       */
 088      public function getBaseUrl()
 089      {
 090          return $this->baseUrl;
 091      }
 092   
 093      /**
 094       * Sets the base URL.
 095       *
 096       * @param string $baseUrl The base URL
 097       *
 098       * @api
 099       */
 100      public function setBaseUrl($baseUrl)
 101      {
 102          $this->baseUrl = $baseUrl;
 103      }
 104   
 105      /**
 106       * Gets the path info.
 107       *
 108       * @return string The path info
 109       */
 110      public function getPathInfo()
 111      {
 112          return $this->pathInfo;
 113      }
 114   
 115      /**
 116       * Sets the path info.
 117       *
 118       * @param string $pathInfo The path info
 119       */
 120      public function setPathInfo($pathInfo)
 121      {
 122          $this->pathInfo = $pathInfo;
 123      }
 124   
 125      /**
 126       * Gets the HTTP method.
 127       *
 128       * The method is always an uppercased string.
 129       *
 130       * @return string The HTTP method
 131       */
 132      public function getMethod()
 133      {
 134          return $this->method;
 135      }
 136   
 137      /**
 138       * Sets the HTTP method.
 139       *
 140       * @param string $method The HTTP method
 141       *
 142       * @api
 143       */
 144      public function setMethod($method)
 145      {
 146          $this->method = strtoupper($method);
 147      }
 148   
 149      /**
 150       * Gets the HTTP host.
 151       *
 152       * The host is always lowercased because it must be treated case-insensitive.
 153       *
 154       * @return string The HTTP host
 155       */
 156      public function getHost()
 157      {
 158          return $this->host;
 159      }
 160   
 161      /**
 162       * Sets the HTTP host.
 163       *
 164       * @param string $host The HTTP host
 165       *
 166       * @api
 167       */
 168      public function setHost($host)
 169      {
 170          $this->host = strtolower($host);
 171      }
 172   
 173      /**
 174       * Gets the HTTP scheme.
 175       *
 176       * @return string The HTTP scheme
 177       */
 178      public function getScheme()
 179      {
 180          return $this->scheme;
 181      }
 182   
 183      /**
 184       * Sets the HTTP scheme.
 185       *
 186       * @param string $scheme The HTTP scheme
 187       *
 188       * @api
 189       */
 190      public function setScheme($scheme)
 191      {
 192          $this->scheme = strtolower($scheme);
 193      }
 194   
 195      /**
 196       * Gets the HTTP port.
 197       *
 198       * @return int The HTTP port
 199       */
 200      public function getHttpPort()
 201      {
 202          return $this->httpPort;
 203      }
 204   
 205      /**
 206       * Sets the HTTP port.
 207       *
 208       * @param int $httpPort The HTTP port
 209       *
 210       * @api
 211       */
 212      public function setHttpPort($httpPort)
 213      {
 214          $this->httpPort = (int) $httpPort;
 215      }
 216   
 217      /**
 218       * Gets the HTTPS port.
 219       *
 220       * @return int The HTTPS port
 221       */
 222      public function getHttpsPort()
 223      {
 224          return $this->httpsPort;
 225      }
 226   
 227      /**
 228       * Sets the HTTPS port.
 229       *
 230       * @param int $httpsPort The HTTPS port
 231       *
 232       * @api
 233       */
 234      public function setHttpsPort($httpsPort)
 235      {
 236          $this->httpsPort = (int) $httpsPort;
 237      }
 238   
 239      /**
 240       * Gets the query string.
 241       *
 242       * @return string The query string without the "?"
 243       */
 244      public function getQueryString()
 245      {
 246          return $this->queryString;
 247      }
 248   
 249      /**
 250       * Sets the query string.
 251       *
 252       * @param string $queryString The query string (after "?")
 253       *
 254       * @api
 255       */
 256      public function setQueryString($queryString)
 257      {
 258          // string cast to be fault-tolerant, accepting null
 259          $this->queryString = (string) $queryString;
 260      }
 261   
 262      /**
 263       * Returns the parameters.
 264       *
 265       * @return array The parameters
 266       */
 267      public function getParameters()
 268      {
 269          return $this->parameters;
 270      }
 271   
 272      /**
 273       * Sets the parameters.
 274       *
 275       * @param array $parameters The parameters
 276       *
 277       * @return RequestContext The current instance, implementing a fluent interface
 278       */
 279      public function setParameters(array $parameters)
 280      {
 281          $this->parameters = $parameters;
 282   
 283          return $this;
 284      }
 285   
 286      /**
 287       * Gets a parameter value.
 288       *
 289       * @param string $name A parameter name
 290       *
 291       * @return mixed The parameter value or null if nonexistent
 292       */
 293      public function getParameter($name)
 294      {
 295          return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
 296      }
 297   
 298      /**
 299       * Checks if a parameter value is set for the given parameter.
 300       *
 301       * @param string $name A parameter name
 302       *
 303       * @return bool True if the parameter value is set, false otherwise
 304       */
 305      public function hasParameter($name)
 306      {
 307          return array_key_exists($name, $this->parameters);
 308      }
 309   
 310      /**
 311       * Sets a parameter value.
 312       *
 313       * @param string $name      A parameter name
 314       * @param mixed  $parameter The parameter value
 315       *
 316       * @api
 317       */
 318      public function setParameter($name, $parameter)
 319      {
 320          $this->parameters[$name] = $parameter;
 321      }
 322  }
 323