public function onKernelResponse(FilterResponseEvent $event)
{
$response = $event->getResponse();
if (null !== $response && $response instanceof PluginResponseInterface) {
//when a route from a plugin is hit
if (!$event->getRequest()->attributes->get('_jarves_is_plugin')) {
//we accept only plugin routes.
return;
}
$pageResponse = $this->pageStack->getPageResponse();
/** @var $content Content */
$content = $event->getRequest()->attributes->get('_content');
//this is later used in ContentTypes\TypePlugin, so it won't execute
//the same plugin again.
$pageResponse->setPluginResponse($content->getId(), $response);
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
//when this was a master request, we need to render the actual content of the page,
//so HttpKernel can return a valid ready rendered response
//if a plugin route has been successfully requested
//we need to handle also the Jarves editor
if ($this->editMode->isEditMode()) {
$this->editMode->registerEditor();
}
$pageResponse->renderContent();
}
//maintain the actual PageResponse
$event->setResponse($pageResponse);
}
}