Skip to content

Commit

Permalink
Only tag glossary items if they exist (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoglo committed Sep 19, 2024
1 parent 1666e8d commit c696f48
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/EventListener/GeneratePageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ public function __invoke(PageModel $pageModel, LayoutModel $layoutModel, PageReg
if ([] !== $arrGlossaryItems)
{
$glossaryConfig = json_encode($arrGlossaryItems);

// Tag the glossary items
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array_map(static fn ($id) => 'contao.db.tl_glossary_item.'.$id, array_column($arrGlossaryItems, 'id')));
}
}
}

Expand All @@ -145,13 +152,6 @@ public function __invoke(PageModel $pageModel, LayoutModel $layoutModel, PageReg

$objTemplate->glossaryConfig = $glossaryConfig;

// Tag glossary items
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array_map(static fn ($id) => 'contao.db.tl_glossary_item.'.$id, array_column($arrGlossaryItems, 'id')));
}

$GLOBALS['TL_BODY'][] = $objTemplate->parse();
}
}

0 comments on commit c696f48

Please sign in to comment.