‪TYPO3CMS  9.5
Request.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected ‪$hashService;
26 
30  protected ‪$format = 'html';
31 
35  protected ‪$method = 'GET';
36 
40  protected ‪$requestUri;
41 
45  protected ‪$baseUri;
46 
50  protected ‪$isCached = false;
51 
55  protected ‪$configurationManager;
56 
60  protected ‪$environmentService;
61 
66  public function ‪injectHashService(\‪TYPO3\CMS\‪Extbase\Security\Cryptography\HashService ‪$hashService)
67  {
68  $this->hashService = ‪$hashService;
69  }
70 
76  {
77  $this->configurationManager = ‪$configurationManager;
78  }
79 
84  public function ‪injectEnvironmentService(\‪TYPO3\CMS\‪Extbase\Service\EnvironmentService ‪$environmentService)
85  {
86  $this->environmentService = ‪$environmentService;
87  }
88 
96  public function ‪setMethod(‪$method)
97  {
98  if (‪$method === '' || strtoupper(‪$method) !== ‪$method) {
99  throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidRequestMethodException('The request method "' . ‪$method . '" is not supported.', 1217778382);
100  }
101  $this->method = ‪$method;
102  }
103 
109  public function ‪getMethod()
110  {
111  return ‪$this->method;
112  }
113 
120  public function ‪setRequestUri(‪$requestUri)
121  {
122  $this->requestUri = ‪$requestUri;
123  }
124 
130  public function ‪getRequestUri()
131  {
132  return ‪$this->requestUri;
133  }
134 
141  public function ‪setBaseUri(‪$baseUri)
142  {
143  $this->baseUri = ‪$baseUri;
144  }
145 
151  public function ‪getBaseUri()
152  {
153  if ($this->environmentService->isEnvironmentInBackendMode()) {
154  return $this->baseUri . TYPO3_mainDir;
155  }
156  return ‪$this->baseUri;
157  }
158 
165  public function ‪setIsCached(‪$isCached)
166  {
167  $this->‪isCached = (bool)‪$isCached;
168  }
169 
176  public function ‪isCached()
177  {
178  return ‪$this->isCached;
179  }
180 
187  public function ‪getReferringRequest()
188  {
189  if (isset($this->internalArguments['__referrer']['@request'])) {
190  $referrerArray = unserialize($this->hashService->validateAndStripHmac($this->internalArguments['__referrer']['@request']), ['allowed_classes' => false]);
191  ‪$arguments = [];
192  if (isset($this->internalArguments['__referrer']['arguments'])) {
193  // This case is kept for compatibility in 7.6 and 6.2, but will be removed in 8
194  ‪$arguments = unserialize(base64_decode($this->hashService->validateAndStripHmac($this->internalArguments['__referrer']['arguments'])));
195  }
196  $referringRequest = new ‪ReferringRequest();
197  $referringRequest->setArguments(array_replace_recursive(‪$arguments, $referrerArray));
198  return $referringRequest;
199  }
200  return null;
201  }
202 }
‪TYPO3\CMS\Extbase\Mvc\Web\Request\getBaseUri
‪string getBaseUri()
Definition: Request.php:143
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$configurationManager
‪TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
Definition: Request.php:48
‪TYPO3
‪TYPO3\CMS\Extbase\Mvc\Web\Request\setIsCached
‪setIsCached($isCached)
Definition: Request.php:157
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:22
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$format
‪string $format
Definition: Request.php:28
‪TYPO3\CMS\Extbase\Mvc\Web\Request\getMethod
‪string getMethod()
Definition: Request.php:101
‪TYPO3\CMS\Extbase\Mvc\Web\Request\injectConfigurationManager
‪injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
Definition: Request.php:67
‪TYPO3\CMS\Extbase\Mvc\Web\Request\setRequestUri
‪setRequestUri($requestUri)
Definition: Request.php:112
‪TYPO3\CMS\Extbase\Mvc\Web\Request\isCached
‪bool isCached()
Definition: Request.php:168
‪TYPO3\CMS\Extbase\Mvc\Web\Request\injectHashService
‪injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService)
Definition: Request.php:58
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$hashService
‪TYPO3 CMS Extbase Security Cryptography HashService $hashService
Definition: Request.php:24
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$environmentService
‪TYPO3 CMS Extbase Service EnvironmentService $environmentService
Definition: Request.php:52
‪TYPO3\CMS\Extbase\Mvc\Web\Request\injectEnvironmentService
‪injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
Definition: Request.php:76
‪TYPO3\CMS\Extbase\Mvc\Web\ReferringRequest
Definition: ReferringRequest.php:21
‪TYPO3\CMS\Extbase\Mvc\Web\Request\getReferringRequest
‪ReferringRequest getReferringRequest()
Definition: Request.php:179
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$requestUri
‪string $requestUri
Definition: Request.php:36
‪TYPO3\CMS\Extbase\Mvc\Web\Request
Definition: Request.php:21
‪TYPO3\CMS\Extbase\Mvc\Web
Definition: AbstractRequestHandler.php:2
‪TYPO3\CMS\Extbase\Mvc\Web\Request\setBaseUri
‪setBaseUri($baseUri)
Definition: Request.php:133
‪TYPO3\CMS\Extbase\Mvc\Web\Request\getRequestUri
‪string getRequestUri()
Definition: Request.php:122
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$method
‪string $method
Definition: Request.php:32
‪TYPO3\CMS\Extbase\Mvc\Web\Request\setMethod
‪setMethod($method)
Definition: Request.php:88
‪TYPO3\CMS\Extbase\Mvc\Request\$arguments
‪array $arguments
Definition: Request.php:60
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$baseUri
‪string $baseUri
Definition: Request.php:40
‪TYPO3\CMS\Extbase\Mvc\Request
Definition: Request.php:23
‪TYPO3\CMS\Extbase\Mvc\Web\Request\$isCached
‪bool $isCached
Definition: Request.php:44