From 7cd604f1ccc781d441e68b51e69f31bd3887511a Mon Sep 17 00:00:00 2001 From: Adam Schubert Date: Thu, 27 Aug 2020 22:31:47 +0200 Subject: [PATCH] feat(Cache): Invalidate cache, Fixes #1 --- .../Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php b/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php index fe1b0ba..6cdb158 100644 --- a/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php +++ b/src/Dravencms/FrontModule/Components/HtmlSnippet/HtmlSnippet/Detail/Detail.php @@ -70,15 +70,20 @@ public function render() $key = __CLASS__ . $htmlSnippetTranslation->getId(); $tempFile = $this->tempnam->load($key, $htmlSnippetTranslation->getUpdatedAt()); - + $invalidateLatteCache = false; if ($tempFile === null) { $temp = file_get_contents(__DIR__ . '/detail.latte'); $temp = strtr($temp, ['' => $htmlSnippetTranslation->getHtml()]); $tempFile = $this->tempnam->save($key, $temp, $htmlSnippetTranslation->getUpdatedAt()); + $invalidateLatteCache = true; } $template->setFile($tempFile); + if ($invalidateLatteCache) { + $latteTmpFile = $template->getLatte()->getCacheFile($template->getFile()); + if (is_file($latteTmpFile)) unlink($latteTmpFile); + } $template->render(); } }