6768bbbc6b49a3b7f12562d19fd3281048e6cfc2
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / MVC / Web / Request.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Represents a web request.
30 *
31 * @package Extbase
32 * @subpackage MVC\Web
33 * @version $ID:$
34 *
35 * @scope prototype
36 * @api
37 */
38 class Tx_Extbase_MVC_Web_Request extends Tx_Extbase_MVC_Request {
39
40 /**
41 * @var string The requested representation format
42 */
43 protected $format = 'html';
44
45 /**
46 * @var string Contains the request method
47 */
48 protected $method = 'GET';
49
50 /**
51 * @var string
52 */
53 protected $requestURI;
54
55 /**
56 * @var string The base URI for this request - ie. the host and path leading to the index.php
57 */
58 protected $baseURI;
59
60 /**
61 * @var boolean TRUE if the HMAC of this request could be verified, FALSE otherwise
62 */
63 protected $hmacVerified = FALSE;
64
65 /**
66 * @var array data of the current cObj
67 */
68 protected $contentObjectData = array();
69
70 /**
71 * @var boolean TRUE if the current request is cached, false otherwise.
72 */
73 protected $isCached = FALSE;
74
75 /**
76 * Sets the request method
77 *
78 * @param string $method Name of the request method
79 * @return void
80 * @throws Tx_Extbase_MVC_Exception_InvalidRequestMethod if the request method is not supported
81 */
82 public function setMethod($method) {
83 if ($method === '' || (strtoupper($method) !== $method)) throw new Tx_Extbase_MVC_Exception_InvalidRequestMethod('The request method "' . $method . '" is not supported.', 1217778382);
84 $this->method = $method;
85 }
86
87 /**
88 * Returns the name of the request method
89 *
90 * @return string Name of the request method
91 * @api
92 */
93 public function getMethod() {
94 return $this->method;
95 }
96
97 /**
98 * Sets the request URI
99 *
100 * @param string $requestURI URI of this web request
101 * @return void
102 */
103 public function setRequestURI($requestURI) {
104 $this->requestURI = $requestURI;
105 }
106
107 /**
108 * Returns the request URI
109 *
110 * @return string URI of this web request
111 * @api
112 */
113 public function getRequestURI() {
114 return $this->requestURI;
115 }
116
117 /**
118 * Sets the base URI for this request.
119 *
120 * @param string $baseURI New base URI
121 * @return void
122 */
123 public function setBaseURI($baseURI) {
124 $this->baseURI = $baseURI;
125 }
126
127 /**
128 * Returns the base URI
129 *
130 * @return string Base URI of this web request
131 * @api
132 */
133 public function getBaseURI() {
134 if (TYPO3_MODE === 'BE') {
135 return $this->baseURI . TYPO3_mainDir;
136 } else {
137 return $this->baseURI;
138 }
139 }
140
141 /**
142 * Could the request be verified via a HMAC?
143 *
144 * @param boolean $hmacVerified TRUE if request could be verified, FALSE otherwise
145 * @return void
146 * @author Sebastian Kurfürst <sebastian@typo3.org>
147 */
148 public function setHmacVerified($hmacVerified) {
149 $this->hmacVerified = (boolean)$hmacVerified;
150 }
151
152 /**
153 * Could the request be verified via a HMAC?
154 *
155 * @return boolean TRUE if request could be verified, FALSE otherwise
156 * @author Sebastian Kurfürst <sebastian@typo3.org>
157 */
158 public function isHmacVerified() {
159 return $this->hmacVerified;
160 }
161
162 /**
163 * Sets the data array of the current content object
164 *
165 * @param array $contentObjectData data of the current cObj
166 * @return void
167 * @author Bastian Waidelich <bastian@typo3.org>
168 */
169 public function setContentObjectData(array $contentObjectData) {
170 $this->contentObjectData = $contentObjectData;
171 }
172
173 /**
174 * Returns the data array of the current content object
175 *
176 * @return array data of the current cObj
177 * @api (v4 only)
178 * @author Bastian Waidelich <bastian@typo3.org>
179 */
180 public function getContentObjectData() {
181 return $this->contentObjectData;
182 }
183
184 /**
185 * Set if the current request is cached.
186 *
187 * @param boolean $isCached
188 */
189 public function setIsCached($isCached) {
190 $this->isCached = (boolean) $isCached;
191 }
192 /**
193 * Return whether the current request is a cached request or not.
194 *
195 * @api (v4 only)
196 * @return boolean the caching status.
197 */
198 public function isCached() {
199 return $this->isCached;
200 }
201 }
202 ?>