TYPO3 API  SVNRelease
Request.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
00006 *  All rights reserved
00007 *
00008 *  This class is a backport of the corresponding class of FLOW3.
00009 *  All credits go to the v5 team.
00010 *
00011 *  This script is part of the TYPO3 project. The TYPO3 project is
00012 *  free software; you can redistribute it and/or modify
00013 *  it under the terms of the GNU General Public License as published by
00014 *  the Free Software Foundation; either version 2 of the License, or
00015 *  (at your option) any later version.
00016 *
00017 *  The GNU General Public License can be found at
00018 *  http://www.gnu.org/copyleft/gpl.html.
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 
00028 /**
00029  * Represents a web request.
00030  *
00031  * @package Extbase
00032  * @subpackage MVC\Web
00033  * @version $ID:$
00034  *
00035  * @scope prototype
00036  * @api
00037  */
00038 class Tx_Extbase_MVC_Web_Request extends Tx_Extbase_MVC_Request {
00039 
00040     /**
00041      * @var string The requested representation format
00042      */
00043     protected $format = 'html';
00044 
00045     /**
00046      * @var string Contains the request method
00047      */
00048     protected $method = 'GET';
00049 
00050     /**
00051      * @var string
00052      */
00053     protected $requestURI;
00054 
00055     /**
00056      * @var string The base URI for this request - ie. the host and path leading to the index.php
00057      */
00058     protected $baseURI;
00059 
00060     /**
00061      * @var boolean TRUE if the HMAC of this request could be verified, FALSE otherwise
00062      */
00063     protected $hmacVerified = FALSE;
00064 
00065     /**
00066      * @var boolean TRUE if the current request is cached, false otherwise.
00067      */
00068     protected $isCached = FALSE;
00069 
00070     /**
00071      * @var Tx_Extbase_Configuration_ConfigurationManagerInterface
00072      */
00073     protected $configurationManager;
00074 
00075     /**
00076      * @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
00077      * @return void
00078      */
00079     public function injectConfigurationManager(Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager) {
00080         $this->configurationManager = $configurationManager;
00081     }
00082 
00083     /**
00084      * Sets the request method
00085      *
00086      * @param string $method Name of the request method
00087      * @return void
00088      * @throws Tx_Extbase_MVC_Exception_InvalidRequestMethod if the request method is not supported
00089      */
00090     public function setMethod($method) {
00091         if ($method === '' || (strtoupper($method) !== $method)) throw new Tx_Extbase_MVC_Exception_InvalidRequestMethod('The request method "' . $method . '" is not supported.', 1217778382);
00092         $this->method = $method;
00093     }
00094 
00095     /**
00096      * Returns the name of the request method
00097      *
00098      * @return string Name of the request method
00099      * @api
00100      */
00101     public function getMethod() {
00102         return $this->method;
00103     }
00104 
00105     /**
00106      * Sets the request URI
00107      *
00108      * @param string $requestURI URI of this web request
00109      * @return void
00110      */
00111     public function setRequestURI($requestURI) {
00112         $this->requestURI = $requestURI;
00113     }
00114 
00115     /**
00116      * Returns the request URI
00117      *
00118      * @return string URI of this web request
00119      * @api
00120      */
00121     public function getRequestURI() {
00122         return $this->requestURI;
00123     }
00124 
00125     /**
00126      * Sets the base URI for this request.
00127      *
00128      * @param string $baseURI New base URI
00129      * @return void
00130      */
00131     public function setBaseURI($baseURI) {
00132         $this->baseURI = $baseURI;
00133     }
00134 
00135     /**
00136      * Returns the base URI
00137      *
00138      * @return string Base URI of this web request
00139      * @api
00140      */
00141     public function getBaseURI() {
00142         if (TYPO3_MODE === 'BE') {
00143             return $this->baseURI . TYPO3_mainDir;
00144         } else {
00145             return $this->baseURI;
00146         }
00147     }
00148 
00149     /**
00150      * Could the request be verified via a HMAC?
00151      *
00152      * @param boolean $hmacVerified TRUE if request could be verified, FALSE otherwise
00153      * @return void
00154      * @author Sebastian Kurfürst <sebastian@typo3.org>
00155      */
00156     public function setHmacVerified($hmacVerified) {
00157         $this->hmacVerified = (boolean)$hmacVerified;
00158     }
00159 
00160     /**
00161      * Could the request be verified via a HMAC?
00162      *
00163      * @return boolean TRUE if request could be verified, FALSE otherwise
00164      * @author Sebastian Kurfürst <sebastian@typo3.org>
00165      */
00166     public function isHmacVerified() {
00167         return $this->hmacVerified;
00168     }
00169 
00170     /**
00171      * Returns the data array of the current content object
00172      *
00173      * @return array data of the current cObj
00174      * @deprecated since Extbase 1.3.0; will be removed in Extbase 1.5.0. Use the ConfigurationManager to retrieve the current ContentObject
00175      * @author Bastian Waidelich <bastian@typo3.org>
00176      */
00177     public function getContentObjectData() {
00178         t3lib_div::logDeprecatedFunction();
00179         $contentObject = $this->configurationManager->getContentObject();
00180         return $contentObject->data;
00181     }
00182 
00183     /**
00184      * Set if the current request is cached.
00185      *
00186      * @param boolean $isCached
00187      */
00188     public function setIsCached($isCached) {
00189         $this->isCached = (boolean) $isCached;
00190     }
00191     /**
00192      * Return whether the current request is a cached request or not.
00193      *
00194      * @api (v4 only)
00195      * @return boolean the caching status.
00196      */
00197     public function isCached() {
00198         return $this->isCached;
00199     }
00200 }
00201 ?>