Skip to content

Commit

Permalink
Bugfix fix trait in TYPO3 11.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesbochmann committed Nov 9, 2023
1 parent 2c3d475 commit f183f1b
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions Classes/ExtBaseFluid/Controller/CacheTagsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Sys25\RnBase\ExtBaseFluid\Controller;

use Psr\Http\Message\ResponseInterface;
use Sys25\RnBase\Utility\TYPO3;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;

/***************************************************************
* Copyright notice
Expand All @@ -27,7 +29,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
/*
* When using this trait you can configure your cache tags like this through TypoScript
* for the actions of a extbase controller:
* plugin.ty_my_ext.settings.cacheTags.$lowerCamelCaseControllerNameOmittingController.$lowerCaseActionNameOmittingAction.0 = my_cache_tag
Expand All @@ -37,18 +39,38 @@
* @license http://www.gnu.org/licenses/lgpl.html
* GNU Lesser General Public License, version 3 or later
*/
trait CacheTagsTrait
{
public function callActionMethod()
if (TYPO3::isTYPO115OrHigher()) {
trait CacheTagsTrait
{
$this->handleCacheTags();
parent::callActionMethod();
}
public function callActionMethod(RequestInterface $request): ResponseInterface
{
$this->handleCacheTags();

return parent::callActionMethod($request);
}

protected function handleCacheTags()
protected function handleCacheTags()
{
$cacheTags = $this->settings['cacheTags'][strtolower($this->request->getControllerName())][$this->request->getControllerActionName()] ?? null;
if ($cacheTags) {
TYPO3::getTSFE()->addCacheTags($cacheTags);
}
}
}
} else {
trait CacheTagsTrait
{
if ($cacheTags = $this->settings['cacheTags'][strtolower($this->request->getControllerName())][$this->request->getControllerActionName()]) {
TYPO3::getTSFE()->addCacheTags($cacheTags);
public function callActionMethod()
{
$this->handleCacheTags();
parent::callActionMethod();
}

protected function handleCacheTags()
{
if ($cacheTags = $this->settings['cacheTags'][strtolower($this->request->getControllerName())][$this->request->getControllerActionName()]) {
TYPO3::getTSFE()->addCacheTags($cacheTags);
}
}
}
}

0 comments on commit f183f1b

Please sign in to comment.