Events
Caution
This page is outdated and does not reflect the current state of the extension. It will be updated soon.
New in version 0.7.0
Feature: #10 - Introduce BeforeRenderingEvent and AfterRenderingEvent
There are several events available that allow to influence the rendering. Event listeners must be registered via the service configuration. More information can be found in the official TYPO3 documentation.
BeforeRenderingEvent
This event is triggered directly before the compiled template is rendered along with the provided data. This allows the data to be manipulated once again before it is passed to the Renderer.
Example:
# Classes/EventListener/BeforeRenderingListener.php
namespace Vendor\Extension\EventListener;
use CPSIT\Typo3Handlebars\Event\BeforeRenderingEvent;
class BeforeRenderingListener
{
public function modifyRenderData(BeforeRenderingEvent $event): void
{
$data = $event->getData();
// Do anything...
$event->setData($data);
}
}
AfterRenderingEvent
After the Renderer has completely rendered the template using the provided data,
the
After is triggered. This can be used to subsequently
influence the rendering result.
Example:
# Classes/EventListener/AfterRenderingListener.php
namespace Vendor\Extension\EventListener;
use CPSIT\Typo3Handlebars\Event\AfterRenderingEvent;
class AfterRenderingListener
{
public function modifyRenderedContent(AfterRenderingEvent $event): void
{
$content = $event->getContent();
// Do anything...
$event->setContent($content);
}
}