/**
  * @test
  */
 public function isActionCacheableReturnsFalseIfActionIsNotCacheable()
 {
     $mockConfiguration = array('controllerConfiguration' => array('SomeController' => array('nonCacheableActions' => array('someAction'))));
     $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($mockConfiguration));
     $actualResult = $this->extensionService->isActionCacheable('SomeExtension', 'SomePlugin', 'SomeController', 'someAction');
     $this->assertFalse($actualResult);
 }
Esempio n. 2
0
 /**
  * Disable cache hash if the action is not cacheable
  * and pointed to from an already uncached request
  *
  * @param array $controllerArguments the current controller arguments
  * @return void
  */
 protected function disableCacheHashForNonCacheableAction(array $controllerArguments)
 {
     if (isset($controllerArguments['action']) && $this->getUseCacheHash()) {
         $actionIsCacheable = $this->extensionService->isActionCacheable(NULL, NULL, $controllerArguments['controller'], $controllerArguments['action']);
         $isRequestCached = $this->request instanceof WebRequest && $this->request->isCached();
         $this->setUseCacheHash($isRequestCached || $actionIsCacheable);
     }
 }
Esempio n. 3
0
 /**
  * Checks if the given action is cacheable or not.
  * In this case disables caching if option enableSearch is set. Useful for search forms in an action
  * which is mostly cached but if you have an search field caching is a problem.
  *
  * @param string $extensionName Name of the target extension, without underscores
  * @param string $pluginName Name of the target plugin
  * @param string $controllerName Name of the target controller
  * @param string $actionName Name of the action to be called
  * @return boolean TRUE if the specified plugin action is cacheable, otherwise FALSE
  */
 public function isActionCacheable($extensionName, $pluginName, $controllerName, $actionName)
 {
     $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
     if ($frameworkConfiguration['settings']['enableSearch'] == 1) {
         return false;
     } else {
         return parent::isActionCacheable($extensionName, $pluginName, $controllerName, $actionName);
     }
 }
 /**
  * Handles the web request. The response will automatically be sent to the client.
  *
  * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface|NULL
  */
 public function handleRequest()
 {
     $request = $this->requestBuilder->build();
     if ($this->extensionService->isActionCacheable(NULL, NULL, $request->getControllerName(), $request->getControllerActionName())) {
         $request->setIsCached(TRUE);
     } else {
         $contentObject = $this->configurationManager->getContentObject();
         if ($contentObject->getUserObjectType() === \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::OBJECTTYPE_USER) {
             $contentObject->convertToUserIntObject();
             // \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::convertToUserIntObject() will recreate the object, so we have to stop the request here
             return NULL;
         }
         $request->setIsCached(FALSE);
     }
     /** @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */
     $response = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     $this->dispatcher->dispatch($request, $response);
     return $response;
 }
Esempio n. 5
0
 /**
  * Handles the web request. The response will automatically be sent to the client.
  *
  * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface|NULL
  */
 public function handleRequest()
 {
     $request = $this->requestBuilder->build();
     if ($this->extensionService->isActionCacheable(null, null, $request->getControllerName(), $request->getControllerActionName())) {
         $request->setIsCached(true);
     } else {
         $contentObject = $this->configurationManager->getContentObject();
         if ($contentObject->getUserObjectType() === \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::OBJECTTYPE_USER) {
             $contentObject->convertToUserIntObject();
             // \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::convertToUserIntObject() will recreate the object, so we have to stop the request here
             return null;
         }
         $request->setIsCached(false);
     }
     if ($this->configurationManager->isFeatureEnabled('requireCHashArgumentForActionArguments')) {
         $pluginNamespace = $this->extensionService->getPluginNamespace($request->getControllerExtensionName(), $request->getPluginName());
         $this->cacheHashEnforcer->enforceForRequest($request, $pluginNamespace);
     }
     /** @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */
     $response = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Response::class);
     $this->dispatcher->dispatch($request, $response);
     return $response;
 }