Skip to content

Commit

Permalink
Add tagging for the missing modules
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Dec 9, 2020
1 parent 5b4a03d commit 996694e
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 37 deletions.
3 changes: 2 additions & 1 deletion calendar-bundle/src/Resources/contao/classes/Events.php
Expand Up @@ -284,7 +284,8 @@ protected function addEvent($objEvents, $intStart, $intEnd, $intBegin, $intLimit
// Tag the event (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_calendar_events.' . $objEvents->id));
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array('contao.db.tl_calendar_events.' . $objEvents->id));
}

// Store raw data
Expand Down
13 changes: 7 additions & 6 deletions calendar-bundle/src/Resources/contao/modules/ModuleCalendar.php
Expand Up @@ -71,12 +71,6 @@ public function generate()
return '';
}

// Tag the calendars (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
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'));
$this->strLink = $this->strUrl;

Expand All @@ -86,6 +80,13 @@ public function generate()
$this->strLink = $objTarget->getFrontendUrl();
}

// Tag the calendars (see #2137)
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 function ($id) { return 'contao.db.tl_calendar.' . $id; }, $this->cal_calendar));
}

return parent::generate();
}

Expand Down
Expand Up @@ -237,12 +237,6 @@ protected function compile()
$objTemplate->hasDetails = false;
$objTemplate->hasTeaser = false;

// Tag the event (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_calendar_events.' . $objEvent->id));
}

// Clean the RTE output
if ($objEvent->teaser)
{
Expand Down Expand Up @@ -398,6 +392,13 @@ protected function compile()

$this->Template->event = $objTemplate->parse();

// Tag the event (see #2137)
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('contao.db.tl_calendar_events.' . $objEvent->id));
}

$bundles = System::getContainer()->getParameter('kernel.bundles');

// HOOK: comments extension required
Expand Down
Expand Up @@ -80,7 +80,8 @@ public function generate()
// Tag the calendars (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
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));
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array_map(static function ($id) { return 'contao.db.tl_calendar.' . $id; }, $this->cal_calendar));
}

return parent::generate();
Expand Down
4 changes: 1 addition & 3 deletions comments-bundle/src/Resources/contao/classes/Comments.php
Expand Up @@ -12,7 +12,6 @@

use Contao\CoreBundle\Exception\PageNotFoundException;
use Contao\CoreBundle\OptIn\OptIn;
use FOS\HttpCache\ResponseTagger;

/**
* Class Comments
Expand Down Expand Up @@ -43,10 +42,9 @@ public function addCommentsToTemplate(FrontendTemplate $objTemplate, \stdClass $

$objTemplate->comments = array(); // see #4064

// Tag the response
// Tag the comment (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
/** @var ResponseTagger $responseTagger */
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array(sprintf('contao.comments.%s.%s', $strSource, $intParent)));
}
Expand Down
Expand Up @@ -10,7 +10,6 @@

namespace Contao;

use FOS\HttpCache\ResponseTagger;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down Expand Up @@ -403,10 +402,9 @@ private function setCacheHeaders(Response $response)
$response->setVary(array('Cookie'));
}

// Tag the response with cache tags für the shared cache only
// Tag the page (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
/** @var ResponseTagger $responseTagger */
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array('contao.db.tl_page.' . $objPage->id));
}
Expand Down
4 changes: 1 addition & 3 deletions core-bundle/src/Resources/contao/elements/ContentElement.php
Expand Up @@ -11,7 +11,6 @@
namespace Contao;

use Contao\Model\Collection;
use FOS\HttpCache\ResponseTagger;

/**
* Parent class for content elements.
Expand Down Expand Up @@ -274,10 +273,9 @@ public function generate()
$this->Template->class .= ' ' . implode(' ', $this->objModel->classes);
}

// Tag the response
// Tag the content element (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
/** @var ResponseTagger $responseTagger */
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array('contao.db.tl_content.' . $this->id));
}
Expand Down
5 changes: 1 addition & 4 deletions core-bundle/src/Resources/contao/elements/ContentModule.php
Expand Up @@ -10,8 +10,6 @@

namespace Contao;

use FOS\HttpCache\ResponseTagger;

/**
* Front end content element "module".
*
Expand Down Expand Up @@ -67,10 +65,9 @@ public function generate()
/** @var Module $objModule */
$objModule = new $strClass($objModel, $this->strColumn);

// Tag the response
// Tag the content element (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
/** @var ResponseTagger $responseTagger */
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array('contao.db.tl_content.' . $this->id));
}
Expand Down
4 changes: 1 addition & 3 deletions core-bundle/src/Resources/contao/modules/Module.php
Expand Up @@ -11,7 +11,6 @@
namespace Contao;

use Contao\Model\Collection;
use FOS\HttpCache\ResponseTagger;

/**
* Parent class for front end modules.
Expand Down Expand Up @@ -236,10 +235,9 @@ public function generate()
$this->Template->class .= ' ' . implode(' ', $this->objModel->classes);
}

// Tag the response
// Tag the module (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
/** @var ResponseTagger $responseTagger */
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array('contao.db.tl_module.' . $this->id));
}
Expand Down
5 changes: 1 addition & 4 deletions core-bundle/src/Resources/contao/modules/ModuleArticle.php
Expand Up @@ -10,8 +10,6 @@

namespace Contao;

use FOS\HttpCache\ResponseTagger;

/**
* Provides methodes to handle articles.
*
Expand Down Expand Up @@ -63,10 +61,9 @@ public function generate($blnNoMarkup=false)
$this->type = 'article';
$this->blnNoMarkup = $blnNoMarkup;

// Tag response
// Tag the article (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
/** @var ResponseTagger $responseTagger */
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array('contao.db.tl_article.' . $this->id));
}
Expand Down
17 changes: 17 additions & 0 deletions faq-bundle/src/Resources/contao/modules/ModuleFaqList.php
Expand Up @@ -69,6 +69,13 @@ public function generate()
return $this->getFrontendModule($this->faq_readerModule, $this->strColumn);
}

// Tag the FAQ categories (see #2137)
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 function ($id) { return 'contao.db.tl_faq_category.' . $id; }, $this->faq_categories));
}

return parent::generate();
}

Expand All @@ -86,6 +93,7 @@ protected function compile()
return;
}

$tags = array();
$arrFaq = array_fill_keys($this->faq_categories, array());

// Add FAQs
Expand All @@ -101,6 +109,15 @@ protected function compile()
$arrFaq[$objFaq->pid]['items'][] = $arrTemp;
$arrFaq[$objFaq->pid]['headline'] = $objPid->headline;
$arrFaq[$objFaq->pid]['title'] = $objPid->title;

$tags[] = 'contao.db.tl_faq.' . $objFaq->id;
}

// Tag the FAQs (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags($tags);
}

$arrFaq = array_values(array_filter($arrFaq));
Expand Down
17 changes: 17 additions & 0 deletions faq-bundle/src/Resources/contao/modules/ModuleFaqPage.php
Expand Up @@ -56,6 +56,13 @@ public function generate()
return '';
}

// Tag the FAQ categories (see #2137)
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 function ($id) { return 'contao.db.tl_faq_category.' . $id; }, $this->faq_categories));
}

return parent::generate();
}

Expand All @@ -76,6 +83,7 @@ protected function compile()
/** @var PageModel $objPage */
global $objPage;

$tags = array();
$arrFaqs = array_fill_keys($this->faq_categories, array());
$projectDir = System::getContainer()->getParameter('kernel.project_dir');

Expand Down Expand Up @@ -126,6 +134,15 @@ protected function compile()
$arrFaqs[$objFaq->pid]['items'][] = $objTemp;
$arrFaqs[$objFaq->pid]['headline'] = $objPid->headline;
$arrFaqs[$objFaq->pid]['title'] = $objPid->title;

$tags[] = 'contao.db.tl_faq.' . $objFaq->id;
}

// Tag the FAQs (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags($tags);
}

$arrFaqs = array_values(array_filter($arrFaqs));
Expand Down
7 changes: 7 additions & 0 deletions faq-bundle/src/Resources/contao/modules/ModuleFaqReader.php
Expand Up @@ -155,6 +155,13 @@ protected function compile()

$this->Template->info = sprintf($GLOBALS['TL_LANG']['MSC']['faqCreatedBy'], Date::parse($objPage->dateFormat, $objFaq->tstamp), $strAuthor);

// Tag the FAQ (see #2137)
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('contao.db.tl_faq.' . $objFaq->id));
}

$bundles = System::getContainer()->getParameter('kernel.bundles');

// HOOK: comments extension required
Expand Down
3 changes: 2 additions & 1 deletion news-bundle/src/Resources/contao/modules/ModuleNews.php
Expand Up @@ -225,7 +225,8 @@ protected function parseArticle($objArticle, $blnAddArchive=false, $strClass='',
// Tag the news (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
System::getContainer()->get('fos_http_cache.http.symfony_response_tagger')->addTags(array('contao.db.tl_news.' . $objArticle->id));
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array('contao.db.tl_news.' . $objArticle->id));
}

return $objTemplate->parse();
Expand Down
Expand Up @@ -76,7 +76,8 @@ public function generate()
// Tag the news archives (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
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));
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array_map(static function ($id) { return 'contao.db.tl_news_archive.' . $id; }, $this->news_archives));
}

return parent::generate();
Expand Down
3 changes: 2 additions & 1 deletion news-bundle/src/Resources/contao/modules/ModuleNewsList.php
Expand Up @@ -69,7 +69,8 @@ public function generate()
// Tag the news archives (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
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));
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags(array_map(static function ($id) { return 'contao.db.tl_news_archive.' . $id; }, $this->news_archives));
}

return parent::generate();
Expand Down
Expand Up @@ -56,6 +56,13 @@ public function generate()
return '';
}

// Tag the channels (see #2137)
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 function ($id) { return 'contao.db.tl_newsletter_channel.' . $id; }, $this->nl_channels));
}

return parent::generate();
}

Expand All @@ -75,6 +82,8 @@ protected function compile()

if ($objNewsletter !== null)
{
$tags = array();

while ($objNewsletter->next())
{
/** @var NewsletterChannelModel $objTarget */
Expand Down Expand Up @@ -119,6 +128,15 @@ protected function compile()
'time' => Date::parse($objPage->timeFormat, $objNewsletter->date),
'channel' => $objNewsletter->pid
);

$tags[] = 'contao.db.tl_newsletter.' . $objNewsletter->id;
}

// Tag the newsletters (see #2137)
if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
{
$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
$responseTagger->addTags($tags);
}
}

Expand Down
Expand Up @@ -134,6 +134,13 @@ protected function compile()

$this->Template->content = $strContent;
$this->Template->subject = $objNewsletter->subject;

// Tag the newsletter (see #2137)
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('contao.db.tl_newsletter.' . $objNewsletter->id));
}
}
}

Expand Down

0 comments on commit 996694e

Please sign in to comment.