diff --git a/calendar-bundle/src/Resources/contao/classes/Events.php b/calendar-bundle/src/Resources/contao/classes/Events.php index 5a8372cde16..26901c8d3bb 100644 --- a/calendar-bundle/src/Resources/contao/classes/Events.php +++ b/calendar-bundle/src/Resources/contao/classes/Events.php @@ -281,21 +281,10 @@ protected function addEvent($objEvents, $intStart, $intEnd, $intBegin, $intLimit } } - // Tag the event and its child content elements (see #2137). Calendars - // will be tagged separately in the related front end modules. + // Tag the event (see #2137) if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { - $arrTags = array('contao.db.tl_calendar_events.' . $objEvents->id); - - if ($objElements = ContentModel::findPublishedByPidAndTable($objEvents->id, 'tl_calendar_events')) - { - foreach ($objElements as $objElement) - { - $arrTags[] = 'contao.db.tl_content.' . $objElement->id; - } - } - - System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags); + System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_calendar_events.' . $objEvents->id)); } // Store raw data diff --git a/calendar-bundle/src/Resources/contao/modules/ModuleCalendar.php b/calendar-bundle/src/Resources/contao/modules/ModuleCalendar.php index 1d8adb5f6e4..8046fc8656b 100644 --- a/calendar-bundle/src/Resources/contao/modules/ModuleCalendar.php +++ b/calendar-bundle/src/Resources/contao/modules/ModuleCalendar.php @@ -71,18 +71,10 @@ public function generate() return ''; } - // Add a response tag for every calendar (see #2137). Events and content - // elements will be tagged automatically in the getAllEvents() method. + // Tag the calendars (see #2137) if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { - $arrTags = array(); - - foreach ($this->cal_calendar as $id) - { - $arrTags[] = 'contao.db.tl_calendar.' . $id; - } - - System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags); + System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_calendar.' . $id; }, $this->cal_calendar)); } $this->strUrl = preg_replace('/\?.*$/', '', Environment::get('request')); diff --git a/calendar-bundle/src/Resources/contao/modules/ModuleEventReader.php b/calendar-bundle/src/Resources/contao/modules/ModuleEventReader.php index 9db0d02b444..0805b130d5b 100644 --- a/calendar-bundle/src/Resources/contao/modules/ModuleEventReader.php +++ b/calendar-bundle/src/Resources/contao/modules/ModuleEventReader.php @@ -237,20 +237,10 @@ protected function compile() $objTemplate->hasDetails = false; $objTemplate->hasTeaser = false; - // Tag the event and its child content elements (see #2137) + // Tag the event (see #2137) if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { - $arrTags = array('contao.db.tl_calendar_events.' . $objEvent->id); - - if ($objElements = ContentModel::findPublishedByPidAndTable($objEvent->id, 'tl_calendar_events')) - { - foreach ($objElements as $objElement) - { - $arrTags[] = 'contao.db.tl_content.' . $objElement->id; - } - } - - System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags); + System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_calendar_events.' . $objEvent->id)); } // Clean the RTE output diff --git a/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php b/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php index bebb949aa8d..d41be29b8b3 100644 --- a/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php +++ b/calendar-bundle/src/Resources/contao/modules/ModuleEventlist.php @@ -77,18 +77,10 @@ public function generate() return $this->getFrontendModule($this->cal_readerModule, $this->strColumn); } - // Add a response tag for every calendar (see #2137). Events and content - // elements will be tagged automatically in the getAllEvents() method. + // Tag the calendars (see #2137) if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { - $arrTags = array(); - - foreach ($this->cal_calendar as $id) - { - $arrTags[] = 'contao.db.tl_calendar.' . $id; - } - - System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags); + System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_calendar.' . $id; }, $this->cal_calendar)); } return parent::generate(); diff --git a/news-bundle/src/Resources/contao/modules/ModuleNews.php b/news-bundle/src/Resources/contao/modules/ModuleNews.php index 56dd69fd147..4d034578eeb 100644 --- a/news-bundle/src/Resources/contao/modules/ModuleNews.php +++ b/news-bundle/src/Resources/contao/modules/ModuleNews.php @@ -222,21 +222,10 @@ protected function parseArticle($objArticle, $blnAddArchive=false, $strClass='', } } - // Tag the news and its child content elements (see #2137). News archives - // will be tagged separately in the related front end modules. + // Tag the news (see #2137) if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { - $arrTags = array('contao.db.tl_news.' . $objArticle->id); - - if ($objElements = ContentModel::findPublishedByPidAndTable($objArticle->id, 'tl_news')) - { - foreach ($objElements as $objElement) - { - $arrTags[] = 'contao.db.tl_content.' . $objElement->id; - } - } - - System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags); + System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_news.' . $objArticle->id)); } return $objTemplate->parse(); diff --git a/news-bundle/src/Resources/contao/modules/ModuleNewsArchive.php b/news-bundle/src/Resources/contao/modules/ModuleNewsArchive.php index b5d34cb61f4..7f1c4067af2 100644 --- a/news-bundle/src/Resources/contao/modules/ModuleNewsArchive.php +++ b/news-bundle/src/Resources/contao/modules/ModuleNewsArchive.php @@ -73,18 +73,10 @@ public function generate() return ''; } - // Add a response tag for every news archive (see #2137). News and content - // elements will be tagged automatically in the parseArticles() method. + // Tag the news archives (see #2137) if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { - $arrTags = array(); - - foreach ($this->news_archives as $id) - { - $arrTags[] = 'contao.db.tl_news_archive.' . $id; - } - - System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags); + System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_news_archive.' . $id; }, $this->news_archives)); } return parent::generate(); diff --git a/news-bundle/src/Resources/contao/modules/ModuleNewsList.php b/news-bundle/src/Resources/contao/modules/ModuleNewsList.php index 243fd23feaa..5a5271027dd 100644 --- a/news-bundle/src/Resources/contao/modules/ModuleNewsList.php +++ b/news-bundle/src/Resources/contao/modules/ModuleNewsList.php @@ -66,18 +66,10 @@ public function generate() return $this->getFrontendModule($this->news_readerModule, $this->strColumn); } - // Add a response tag for every news archive (see #2137). News and content - // elements will be tagged automatically in the parseArticles() method. + // Tag the news archives (see #2137) if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { - $arrTags = array(); - - foreach ($this->news_archives as $id) - { - $arrTags[] = 'contao.db.tl_news_archive.' . $id; - } - - System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags($arrTags); + System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array_map(static function ($id) { return 'contao.db.tl_news_archive.' . $id; }, $this->news_archives)); } return parent::generate();