TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
extbase/Classes/Mvc/Web/Request.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\Web;
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 
23 {
27  protected $hashService;
28 
32  protected $format = 'html';
33 
37  protected $method = 'GET';
38 
42  protected $requestUri;
43 
47  protected $baseUri;
48 
52  protected $isCached = false;
53 
58 
63 
67  public function injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService)
68  {
69  $this->hashService = $hashService;
70  }
71 
75  public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
76  {
77  $this->configurationManager = $configurationManager;
78  }
79 
83  public function injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
84  {
85  $this->environmentService = $environmentService;
86  }
87 
95  public function setMethod($method)
96  {
97  if ($method === '' || strtoupper($method) !== $method) {
98  throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidRequestMethodException('The request method "' . $method . '" is not supported.', 1217778382);
99  }
100  $this->method = $method;
101  }
102 
109  public function getMethod()
110  {
111  return $this->method;
112  }
113 
120  public function setRequestUri($requestUri)
121  {
122  $this->requestUri = $requestUri;
123  }
124 
131  public function getRequestUri()
132  {
133  return $this->requestUri;
134  }
135 
142  public function setBaseUri($baseUri)
143  {
144  $this->baseUri = $baseUri;
145  }
146 
153  public function getBaseUri()
154  {
155  if ($this->environmentService->isEnvironmentInBackendMode()) {
156  return $this->baseUri . TYPO3_mainDir;
157  } else {
158  return $this->baseUri;
159  }
160  }
161 
167  public function setIsCached($isCached)
168  {
169  $this->isCached = (bool)$isCached;
170  }
171 
178  public function isCached()
179  {
180  return $this->isCached;
181  }
182 
188  public function getReferringRequest()
189  {
190  if (isset($this->internalArguments['__referrer']['@request'])) {
191  $referrerArray = unserialize($this->hashService->validateAndStripHmac($this->internalArguments['__referrer']['@request']));
192  $arguments = [];
193  if (isset($this->internalArguments['__referrer']['arguments'])) {
194  // This case is kept for compatibility in 7.6 and 6.2, but will be removed in 8
195  $arguments = unserialize(base64_decode($this->hashService->validateAndStripHmac($this->internalArguments['__referrer']['arguments'])));
196  }
197  $referringRequest = new ReferringRequest();
198  $referringRequest->setArguments(array_replace_recursive($arguments, $referrerArray));
199  return $referringRequest;
200  }
201  return null;
202  }
203 }
injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService)
injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)