[TYPO3-dev] How does extbase determine if non-cachable action is called

Dirk Wenzel wenzel at webfox03.de
Mon Apr 8 09:54:22 CEST 2013


Hi Krystian,
thanks a lot for re-posting your solution.

In short you
- subclass Tx_Extbase_Service_ExtensionService
- overwrite its public function isActionCacheable
- extend this function to evaluate a flexform setting and
- remap the extbase object to your subclass

Since the method is public it should be possible to call the original 
function from the parent instead of copying its content:

class Tx_Vcs_Service_ExtensionService extends 
Tx_Extbase_Service_ExtensionService implements t3lib_Singleton {
     /**
  	[...]
      */
public function isActionCacheable($extensionName, $pluginName, 
$controllerName, $actionName) {
           $frameworkConfiguration = 
$this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 

  $extensionName, $pluginName);

           if (parent::isActionCacheable ($extensionName, $pluginName, 
$controllerName, $pluginName)
||

  isset($frameworkConfiguration['settings']['cache']['makeNonCachable'])
               &&
  $frameworkConfiguration['settings']['cache']['makeNonCachable']) {
                   return FALSE;
           }
           return TRUE;
       }

  }

@all: Would you consider this a good solution? Why does the service 
object not allow to simply set an attribute like: 
setActionCacheable(boolean)

Kind regards
Dirk

Am 07.04.13 21:31, schrieb Krystian Szymukowicz:
> W dniu 2013-04-05 21:45, Dirk Wenzel pisze:
>> Hi Krystian,
>> thank you for your hint.
>> Unfortunatley I was not able to find a readable version of your post.
>>
>> Could you please post it anywhere else?
>>
>> Kind regards
>> Dirk
>>
>>
>> Am 05.04.13 10:53, schrieb Krystian Szymukowicz:
>>>> But the post is without any code, the XML and PHP got lost. So you
>>>> did a
>>>> core hack in ExtensionService.php?
>>>
>>> I am sure google have this somewhere with the proper code.
>
>
> Here it is. The part of my previous post:
>
> SOLUTION:
>
> It would be great to have ability to change the USER_INT based on
> flexform settings of plugin.
> So whole plugin no matter of what action is set can be made USER_INT.
>
> This is quite simple in implementation:
> FLEXFORM:
>
>          <cache>
>              <ROOT>
>                  <TCEforms>
>                      <sheetTitle>Cache</sheetTitle>
>                  </TCEforms>
>                  <type>array</type>
>                  <el>
>                      <settings.cache.makeNonCachable>
>                          <TCEforms>
>                              <label>Make non cachable</label>
>                              <config>
>                                  <type>check</type>
>                              </config>
>                          </TCEforms>
>                      </settings.cache.makeNonCachable>
>                  </el>
>              </ROOT>
>          </cache>
>
>
> Then the TYPO3 sourcecode:
> /typo3/sysext/extbase/Classes/Service/ExtensionService.php
>
> public function isActionCacheable
>
> The flexform setting inside this function is available under:
> $frameworkConfiguration['settings']['cache']['makeNonCachable']
>
>
> As I wrote in previos post this can be overwriten by TS:
> # overwriting classes
> config.tx_extbase.objects {
> # overwrite class to allow USER_INT from flexform
>      Tx_Extbase_Service_ExtensionService {
>          className = Tx_Vcs_Service_ExtensionService
>      }
> }
>
>
> Then in file Classes/Service/ExtensionService.php
>
> class Tx_Vcs_Service_ExtensionService extends
> Tx_Extbase_Service_ExtensionService implements t3lib_Singleton {
>
>      /**
>       * Checks if the given action is cacheable or not.
>       *
>       * @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(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
> $extensionName, $pluginName);
>
>          if
> (isset($frameworkConfiguration['controllerConfiguration'][$controllerName])
>              &&
> is_array($frameworkConfiguration['controllerConfiguration'][$controllerName])
>
>              &&
> is_array($frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])
>
>              && in_array($actionName,
> $frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])
>
>              ||
>
> isset($frameworkConfiguration['settings']['cache']['makeNonCachable'])
>              &&
> $frameworkConfiguration['settings']['cache']['makeNonCachable']) {
>                  return FALSE;
>          }
>          return TRUE;
>      }
>
> }
>
>
> Of course the Tx_Vcs must be changed to whatever extension you have
> there for such modification.
>
>
> --
> grtz
> Krystian Szymukowicz




More information about the TYPO3-dev mailing list