Skip to content

Commit

Permalink
[FIX] Make sure cHash calculation works as expected
Browse files Browse the repository at this point in the history
Closes #146
  • Loading branch information
fnagel committed Oct 1, 2016
1 parent 907f648 commit e3c00a1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
*/
protected $log;

/**
* Actions which need a configured cHash
*
* @var array
*/
protected $cHashActions = array();

/**
* Injects the Configuration Manager and is initializing the framework settings
* Function is used to override the merge of settings via TS & flexforms
Expand Down Expand Up @@ -90,6 +97,7 @@ protected function initializeAction()
{
$this->validateTypoScriptConfiguration();
$this->addDefaultCacheTags();
$this->configureCHash();
}

/**
Expand Down Expand Up @@ -239,4 +247,14 @@ protected function addDefaultCacheTags()
$cacheTagsSet = true;
}
}

/**
* Add basic cache tag for all related pages.
*/
protected function configureCHash()
{
if (count($this->cHashActions) > 0 && in_array($this->actionMethodName, $this->cHashActions)) {
\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->reqCHash();
}
}
}
7 changes: 7 additions & 0 deletions Classes/Controller/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
*/
class CategoryController extends AbstractController
{
/**
* @var array
*/
protected $cHashActions = array(
'showAction',
);

/**
* categoryRepository.
*
Expand Down
9 changes: 9 additions & 0 deletions Classes/Controller/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
*/
class CommentController extends AbstractController
{
/**
* @var array
*/
protected $cHashActions = array(
'listAction',
'latestAction',
'showAction',
);

/**
* commentRepository.
*
Expand Down
11 changes: 11 additions & 0 deletions Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
*/
class PostController extends AbstractController
{

/**
* @var array
*/
protected $cHashActions = array(
'categoryAction',
'authorAction',
'tagAction',
'showAction',
);

/**
* postRepository.
*
Expand Down

0 comments on commit e3c00a1

Please sign in to comment.