Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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