Added page and content properties to onOutputGenerated and onOutputRendered events

This commit is contained in:
Matias Griese
2021-05-12 14:49:34 +03:00
parent 5f66f2c4a9
commit 0866753617
2 changed files with 13 additions and 7 deletions

View File

@@ -3,6 +3,7 @@
1. [](#improved)
* Allow optional start date in page collections [#3350](https://github.com/getgrav/grav/pull/3350)
* Added page and content properties to `onOutputGenerated` and `onOutputRendered` events
1. [](#bugfix)
* Fixed twig deprecated TwigFilter messages [#3348](https://github.com/getgrav/grav/issues/3348)
* Fixed fatal error with some markdown links [getgrav/grav-premium-issues#95](https://github.com/getgrav/grav-premium-issues/issues/95)

View File

@@ -14,6 +14,7 @@ use Grav\Framework\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RocketTheme\Toolbox\Event\Event;
/**
* Class RenderProcessor
@@ -42,23 +43,27 @@ class RenderProcessor extends ProcessorBase
return $output;
}
ob_start();
/** @var PageInterface $page */
$page = $this->container['page'];
// Use internal Grav output.
$container->output = $output;
$container->fireEvent('onOutputGenerated');
ob_start();
$event = new Event(['page' => $page, 'output' => &$container->output]);
$container->fireEvent('onOutputGenerated', $event);
echo $container->output;
$html = ob_get_clean();
// remove any output
$container->output = '';
$this->container->fireEvent('onOutputRendered');
$event = new Event(['page' => $page, 'html' => &$html]);
$this->container->fireEvent('onOutputRendered', $event);
$html = ob_get_clean();
/** @var PageInterface $page */
$page = $this->container['page'];
$this->stopTimer();
return new Response($page->httpResponseCode(), $page->httpHeaders(), $html);