1c41d8bf1ee5019888960057abab25195d1b8f93
[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 * Sets the request method
72 *
73 * @param string $method Name of the request method
74 * @return void
75 * @throws Tx_Extbase_MVC_Exception_InvalidRequestMethod if the request method is not supported
76 */
77 public function setMethod($method) {
78 if ($method === '' || (strtoupper($method) !== $method)) throw new Tx_Extbase_MVC_Exception_InvalidRequestMethod('The request method "' . $method . '" is not supported.', 1217778382);
79 $this->method = $method;
80 }
81
82 /**
83 * Returns the name of the request method
84 *
85 * @return string Name of the request method
86 * @api
87 */
88 public function getMethod() {
89 return $this->method;
90 }
91
92 /**
93 * Sets the request URI
94 *
95 * @param string $requestURI URI of this web request
96 * @return void
97 */
98 public function setRequestURI($requestURI) {
99 $this->requestURI = $requestURI;
100 }
101
102 /**
103 * Returns the request URI
104 *
105 * @return string URI of this web request
106 * @api
107 */
108 public function getRequestURI() {
109 return $this->requestURI;
110 }
111
112 /**
113 * Sets the base URI for this request.
114 *
115 * @param string $baseURI New base URI
116 * @return void
117 */
118 public function setBaseURI($baseURI) {
119 $this->baseURI = $baseURI;
120 }
121
122 /**
123 * Returns the base URI
124 *
125 * @return string Base URI of this web request
126 * @api
127 */
128 public function getBaseURI() {
129 if (TYPO3_MODE === 'BE') {
130 return $this->baseURI . TYPO3_mainDir;
131 } else {
132 return $this->baseURI;
133 }
134 }
135
136 /**
137 * Could the request be verified via a HMAC?
138 *
139 * @param boolean $hmacVerified TRUE if request could be verified, FALSE otherwise
140 * @return void
141 * @author Sebastian Kurfürst <sebastian@typo3.org>
142 */
143 public function setHmacVerified($hmacVerified) {
144 $this->hmacVerified = (boolean)$hmacVerified;
145 }
146
147 /**
148 * Could the request be verified via a HMAC?
149 *
150 * @return boolean TRUE if request could be verified, FALSE otherwise
151 * @author Sebastian Kurfürst <sebastian@typo3.org>
152 */
153 public function isHmacVerified() {
154 return $this->hmacVerified;
155 }
156
157 /**
158 * Sets the data array of the current content object
159 *
160 * @param array $contentObjectData data of the current cObj
161 * @return void
162 * @author Bastian Waidelich <bastian@typo3.org>
163 */
164 public function setContentObjectData(array $contentObjectData) {
165 $this->contentObjectData = $contentObjectData;
166 }
167
168 /**
169 * Returns the data array of the current content object
170 *
171 * @return array data of the current cObj
172 * @api (v4 only)
173 * @author Bastian Waidelich <bastian@typo3.org>
174 */
175 public function getContentObjectData() {
176 return $this->contentObjectData;
177 }
178 }
179 ?>