/** * Reads the necessary data from the flexform, builds the web service * request url and gets the data from the web serivce. * * @param string $content the PlugIn content * @param array $conf the PlugIn configuration * * @return string The string containing the template output or an error message * if debug is enabled. */ public function main($content, $conf) { $this->pi_USER_INT_obj = 1; $this->conf = $conf; //no cache when logged into backend or no_cache parameter set $useCache = $GLOBALS['BE_USER']->user == null && !isset($_REQUEST['no_cache']); $cacheId = sha1($this->cObj->data['pi_flexform'] . $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); $content = $this->cache->get($cacheId); if ($content === false || !$useCache) { $content = $this->render(); $this->cache->set($cacheId, $content, array(), $this->cacheLifeTime); } return $this->pi_wrapInBaseClass($content); }
/** * Constructs the cache * * @param string $identifier A identifier which describes this cache * @param t3lib_cache_backend_PhpCapableBackend $backend Backend to be used for this cache * @author Robert Lemke <*****@*****.**> */ public function __construct($identifier, t3lib_cache_backend_PhpCapableBackend $backend) { parent::__construct($identifier, $backend); }
/** * @test * @author Karsten Dambekalns <*****@*****.**> * @author Ingo Renner <*****@*****.**> */ public function getByTagCallsBackend() { $tag = 'sometag'; $identifiers = array('one', 'two'); $entries = array('one value', 'two value'); $backend = $this->getMock('t3lib_cache_backend_AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'findIdentifiersByTags', 'flush', 'flushByTag', 'flushByTags', 'collectGarbage'), array(), '', FALSE); $backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers)); $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls('one value', 'two value')); $cache = new t3lib_cache_frontend_StringFrontend('StringFrontend', $backend); $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries'); }