From 19322e4287acfe40936f852285698a64c16575a1 Mon Sep 17 00:00:00 2001 From: Fritz Michael Gschwantner Date: Wed, 23 Apr 2025 16:45:54 +0100 Subject: [PATCH] Add cache tags --- library/alnv/CatalogView.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/library/alnv/CatalogView.php b/library/alnv/CatalogView.php index 434c54ac..4d910ad2 100644 --- a/library/alnv/CatalogView.php +++ b/library/alnv/CatalogView.php @@ -2,6 +2,8 @@ namespace CatalogManager; +use Contao\System; + class CatalogView extends CatalogController { @@ -769,6 +771,17 @@ public function getCatalogView($arrQuery) $arrCatalogs[] = $arrCatalog; } + if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { + $responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger'); + $tag = 'contao.db.'.$this->catalogTablename; + + if ('view' === $this->strMode) { + $responseTagger->addTags([$tag]); + } elseif ('master' === $this->strMode) { + $responseTagger->addTags(array_map(static function ($record) use ($tag) { return $tag.'.'.$record['id']; }, $arrCatalogs)); + } + } + if ($intPerPage > 0 && $this->catalogAddPagination && $this->strMode == 'view') { $this->objMainTemplate->pagination = $this->TemplateHelper->addPagination($intTotal, $intPerPage, $strPageID, ($this->arrViewPage['id'] ?? '')); @@ -1605,4 +1618,4 @@ public function getCatalogFields() return $this->arrCatalogFields; } -} \ No newline at end of file +}