1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 17:54:44 +02:00

Add feature requested in PR #136 - Allow modification of CacheFile string before output

Co-authored-by: ethanbeyer <ethan.beyer@gmail.com>
This commit is contained in:
Ryan Cramer
2021-05-12 09:43:57 -04:00
parent 143ae7535b
commit 24578306b7

View File

@@ -11,8 +11,9 @@
* https://processwire.com
*
* @method renderPage(HookEvent $event)
* @method clearCacheFileAll(Page $page)
* @method clearCacheFilePages(PageArray $items, Page $page)
* @method void clearCacheFileAll(Page $page)
* @method void clearCacheFilePages(PageArray $items, Page $page)
* @method string saveCacheFileReady(Page $page, $data)
*
*/
@@ -327,6 +328,22 @@ class PageRender extends WireData implements Module, ConfigurableModule {
}
}
/**
* Hook called when cache file is about to be saved for a Page
*
* #pw-hooker
*
* @param Page $page
* @param string $data Data that will be saved to cache file
* @return string Data to save to cache file
* @since 3.0.178
*
*/
public function ___saveCacheFileReady(Page $page, $data) {
if($page) {} // ignore
return $data;
}
/**
* Hook called before any other hooks to Page::render
*
@@ -547,7 +564,11 @@ class PageRender extends WireData implements Module, ConfigurableModule {
}
}
if($data && $cacheAllowed && $cacheFile) $cacheFile->save($data);
if($data && $cacheAllowed && $cacheFile) {
$data = $this->saveCacheFileReady($page, $data);
$cacheFile->save($data);
}
$event->return = $data;
if(!$of) $page->of($of);