[~TAKS] Extbase (MVC): FrontendRequestHandler now retrieves the current cObject throu...
[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 boolean TRUE if the current request is cached, false otherwise.
67 */
68 protected $isCached = FALSE;
69
70 /**
71 * @var Tx_Extbase_Configuration_ConfigurationManagerInterface
72 */
73 protected $configurationManager;
74
75 /**
76 * @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
77 * @return void
78 */
79 public function injectConfigurationManager(Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager) {
80 $this->configurationManager = $configurationManager;
81 }
82
83 /**
84 * Sets the request method
85 *
86 * @param string $method Name of the request method
87 * @return void
88 * @throws Tx_Extbase_MVC_Exception_InvalidRequestMethod if the request method is not supported
89 */
90 public function setMethod($method) {
91 if ($method === '' || (strtoupper($method) !== $method)) throw new Tx_Extbase_MVC_Exception_InvalidRequestMethod('The request method "' . $method . '" is not supported.', 1217778382);
92 $this->method = $method;
93 }
94
95 /**
96 * Returns the name of the request method
97 *
98 * @return string Name of the request method
99 * @api
100 */
101 public function getMethod() {
102 return $this->method;
103 }
104
105 /**
106 * Sets the request URI
107 *
108 * @param string $requestURI URI of this web request
109 * @return void
110 */
111 public function setRequestURI($requestURI) {
112 $this->requestURI = $requestURI;
113 }
114
115 /**
116 * Returns the request URI
117 *
118 * @return string URI of this web request
119 * @api
120 */
121 public function getRequestURI() {
122 return $this->requestURI;
123 }
124
125 /**
126 * Sets the base URI for this request.
127 *
128 * @param string $baseURI New base URI
129 * @return void
130 */
131 public function setBaseURI($baseURI) {
132 $this->baseURI = $baseURI;
133 }
134
135 /**
136 * Returns the base URI
137 *
138 * @return string Base URI of this web request
139 * @api
140 */
141 public function getBaseURI() {
142 if (TYPO3_MODE === 'BE') {
143 return $this->baseURI . TYPO3_mainDir;
144 } else {
145 return $this->baseURI;
146 }
147 }
148
149 /**
150 * Could the request be verified via a HMAC?
151 *
152 * @param boolean $hmacVerified TRUE if request could be verified, FALSE otherwise
153 * @return void
154 * @author Sebastian Kurfürst <sebastian@typo3.org>
155 */
156 public function setHmacVerified($hmacVerified) {
157 $this->hmacVerified = (boolean)$hmacVerified;
158 }
159
160 /**
161 * Could the request be verified via a HMAC?
162 *
163 * @return boolean TRUE if request could be verified, FALSE otherwise
164 * @author Sebastian Kurfürst <sebastian@typo3.org>
165 */
166 public function isHmacVerified() {
167 return $this->hmacVerified;
168 }
169
170 /**
171 * Returns the data array of the current content object
172 *
173 * @return array data of the current cObj
174 * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0. Use the ConfigurationManager to retrieve the current ContentObject
175 * @author Bastian Waidelich <bastian@typo3.org>
176 */
177 public function getContentObjectData() {
178 t3lib_div::logDeprecatedFunction();
179 $contentObject = $this->configurationManager->getContentObject();
180 return $contentObject->data;
181 }
182
183 /**
184 * Set if the current request is cached.
185 *
186 * @param boolean $isCached
187 */
188 public function setIsCached($isCached) {
189 $this->isCached = (boolean) $isCached;
190 }
191 /**
192 * Return whether the current request is a cached request or not.
193 *
194 * @api (v4 only)
195 * @return boolean the caching status.
196 */
197 public function isCached() {
198 return $this->isCached;
199 }
200 }
201 ?>