Fixed Flex Pages not calling onPageProcessed event when cached

This commit is contained in:
Matias Griese
2019-10-07 13:45:49 +03:00
parent 2a6276a941
commit b641b0e442
3 changed files with 14 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
1. [](#bugfix)
* Fixed `Page::untranslatedLanguages()` not being symmetrical to `Page::translatedLanguages()`
* Fixed `Flex Pages` not calling `onPageProcessed` event when cached
# v1.7.0-beta.10
## 10/03/2019

View File

@@ -702,7 +702,12 @@ class Pages
$instance = $this->instances[(string)$path] ?? null;
if (\is_string($instance)) {
$instance = $this->flex ? $this->flex->getObject($instance) : null;
$instance = $instance->hasTranslation() ? $instance->getTranslation() : $instance;
if ($instance) {
$instance = $instance->hasTranslation() ? $instance->getTranslation() : $instance;
if (method_exists($instance, 'initialize') && $this->grav['config']->get('system.pages.events.page')) {
$instance->initialize();
}
}
}
if ($instance && !$instance instanceof PageInterface) {
throw new \RuntimeException('Routing failed on unknown type', 500);
@@ -1325,7 +1330,12 @@ class Pages
*/
foreach ($collection as $key => $page) {
if ($config->get('system.pages.events.page')) {
$this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
if (method_exists($page, 'initialize')) {
$page->initialize();
} else {
// TODO: Deprecated, only used in 1.7 betas.
$this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
}
}
$path = $page->path();

View File

@@ -170,6 +170,7 @@ class PageSystemValidatorCommand extends ConsoleCommand
// Pages
$grav['pages']->init();
$grav->fireEvent('onPagesInitialized', new Event(['pages' => $grav['pages']]));
$grav->fireEvent('onPageInitialized', new Event(['page' => $grav['page']]));
if ($this->input->getOption('record')) {
$this->output->writeln('Pages: ' . $config->get('system.pages.type', 'page'));