if (isset($this->cObj->data) && is_array($this->cObj->data)) {
// we need to check the above conditions as cObj is not available in Backend.
$request->setContentObjectData($this->cObj->data);
+ $request->setIsCached($this->cObj->getUserObjectType() == tslib_cObj::OBJECTTYPE_USER);
}
$response = t3lib_div::makeInstance('Tx_Extbase_MVC_Web_Response');
*/
protected $contentObjectData = array();
+ /**
+ * @var boolean TRUE if the current request is cached, false otherwise.
+ */
+ protected $isCached = FALSE;
+
/**
* Sets the request method
*
public function getContentObjectData() {
return $this->contentObjectData;
}
+
+ /**
+ * Set if the current request is cached.
+ *
+ * @param boolean $isCached
+ */
+ public function setIsCached($isCached) {
+ $this->isCached = (boolean) $isCached;
+ }
+ /**
+ * Return whether the current request is a cached request or not.
+ *
+ * @api (v4 only)
+ * @return boolean the caching status.
+ */
+ public function isCached() {
+ return $this->isCached;
+ }
}
?>
\ No newline at end of file
--- /dev/null
+<?php
+/***************************************************************
+* Copyright notice
+*
+* (c) 2010 Sebastian Kurfuerst <sebastian@typo3.org>
+* All rights reserved
+*
+* This class is a backport of the corresponding class of FLOW3.
+* All credits go to the v5 team.
+*
+* This script is part of the TYPO3 project. The TYPO3 project is
+* free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+class Tx_Extbase_MVC_Web_RequestTest extends Tx_Extbase_BaseTestCase {
+ /**
+ * @test
+ */
+ public function isCachedReturnsFalseByDefault() {
+ $request = new Tx_Extbase_MVC_Web_Request();
+ $this->assertFalse($request->isCached());
+ }
+
+ /**
+ * @test
+ */
+ public function isCachedReturnsTheValueWhichWasPreviouslySet() {
+ $request = new Tx_Extbase_MVC_Web_Request();
+ $request->setIsCached(TRUE);
+ $this->assertTrue($request->isCached());
+ }
+}
+?>
\ No newline at end of file