Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 51f3332

Browse files
Add cache clearing and annotate controllers
1 parent 39cb4d5 commit 51f3332

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

‎Classes/Controller/GalleryController.php‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Digicademy\CHFBase\Domain\Repository\AbstractResourceRepository;
1313
use Digicademy\CHFMedia\Domain\Model\FileGroup;
1414
use Psr\Http\Message\ResponseInterface;
15+
use TYPO3\CMS\Core\Cache\CacheTag;
1516
use TYPO3\CMS\Extbase\Domain\Model\File;
1617
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
1718

@@ -29,22 +30,63 @@ public function injectAbstractResourceRepository(AbstractResourceRepository $abs
2930
$this->abstractResourceRepository = $abstractResourceRepository;
3031
}
3132

33+
/**
34+
* Show file and file group list
35+
*
36+
* @return ResponseInterface
37+
*/
3238
public function indexAction(): ResponseInterface
3339
{
40+
// Get resource
3441
$resourceIdentifier = $this->settings['resource'];
3542
$this->view->assign('resource', $this->abstractResourceRepository->findByIdentifier($resourceIdentifier));
43+
44+
// Set cache tag
45+
$this->request->getAttribute('frontend.cache.collector')->addCacheTags(
46+
new CacheTag('chf')
47+
);
48+
49+
// Create response
3650
return $this->htmlResponse();
3751
}
3852

53+
/**
54+
* Show single file
55+
*
56+
* @param File $singleFile
57+
* @return ResponseInterface
58+
*/
3959
public function showSingleAction(File $singleFile): ResponseInterface
4060
{
61+
// Get single file
4162
$this->view->assign('singleFile', $singleFile);
63+
64+
// Set cache tag
65+
$this->request->getAttribute('frontend.cache.collector')->addCacheTags(
66+
new CacheTag('chf')
67+
);
68+
69+
// Create response
4270
return $this->htmlResponse();
4371
}
4472

73+
/**
74+
* Show single file group
75+
*
76+
* @param FileGroup $fileGroup
77+
* @return ResponseInterface
78+
*/
4579
public function showGroupAction(FileGroup $fileGroup): ResponseInterface
4680
{
81+
// Get file group
4782
$this->view->assign('fileGroup', $fileGroup);
83+
84+
// Set cache tag
85+
$this->request->getAttribute('frontend.cache.collector')->addCacheTags(
86+
new CacheTag('chf')
87+
);
88+
89+
// Create response
4890
return $this->htmlResponse();
4991
}
5092
}

0 commit comments

Comments
 (0)