TYPO3 CMS  TYPO3_6-2
Request.php
Go to the documentation of this file.
1 <?php
3 
22 
27  protected $hashService;
28 
32  protected $format = 'html';
33 
37  protected $method = 'GET';
38 
42  protected $requestUri;
43 
47  protected $baseUri;
48 
53  protected $hmacVerified = FALSE;
54 
58  protected $isCached = FALSE;
59 
65 
71 
79  public function setMethod($method) {
80  if ($method === '' || strtoupper($method) !== $method) {
81  throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidRequestMethodException('The request method "' . $method . '" is not supported.', 1217778382);
82  }
83  $this->method = $method;
84  }
85 
92  public function getMethod() {
93  return $this->method;
94  }
95 
102  public function setRequestUri($requestUri) {
103  $this->requestUri = $requestUri;
104  }
105 
112  public function getRequestUri() {
113  return $this->requestUri;
114  }
115 
122  public function setBaseUri($baseUri) {
123  $this->baseUri = $baseUri;
124  }
125 
132  public function getBaseUri() {
133  if ($this->environmentService->isEnvironmentInBackendMode()) {
134  return $this->baseUri . TYPO3_mainDir;
135  } else {
136  return $this->baseUri;
137  }
138  }
139 
147  public function setHmacVerified($hmacVerified) {
148  $this->hmacVerified = (boolean) $hmacVerified;
149  }
150 
157  public function isHmacVerified() {
158  return $this->hmacVerified;
159  }
160 
166  public function setIsCached($isCached) {
167  $this->isCached = (boolean) $isCached;
168  }
169 
176  public function isCached() {
177  return $this->isCached;
178  }
179 
185  public function getReferringRequest() {
186  $referrerArray = $this->getValidatedReferrerArguments();
187  if ($referrerArray !== NULL) {
188  $arguments = array();
189  if (isset($this->internalArguments['__referrer']['arguments'])) {
190  // This case is kept for compatibility in 7.6 and 6.2, but will be removed in 8
191  $arguments = unserialize(base64_decode($this->hashService->validateAndStripHmac($this->internalArguments['__referrer']['arguments'])));
192  }
193  $referringRequest = new ReferringRequest();
194  $referringRequest->setArguments(\TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($arguments, $referrerArray));
195  return $referringRequest;
196  }
197  return NULL;
198  }
199 
205  public function getValidatedReferrerArguments() {
206  if (isset($this->internalArguments['__referrer']['@request'])) {
207  $referrerArguments = unserialize($this->hashService->validateAndStripHmac($this->internalArguments['__referrer']['@request']));
208  if (!is_array($referrerArguments)) {
209  $referrerArguments = NULL;
210  }
211  return $referrerArguments;
212  }
213  return NULL;
214  }
215 }