/** * @param FilterResponseEvent $event */ public function onKernelResponse(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } try { if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) { return; } } catch (AuthenticationCredentialsNotFoundException $e) { return; } $request = $event->getRequest(); if ($request->isXmlHttpRequest()) { return; } $response = $event->getResponse(); if ($response->isRedirection() || false === strpos($response->headers->get('Content-Type', ''), 'text/html')) { return; } $html = $this->editor->renderEditor($response); if (!empty($html)) { $this->injectEditor($response, $html); } }