/** * Appends analytics scripts into body. * * @param FilterResponseEvent $event */ public function onResponse(FilterResponseEvent $event) { if (0 !== strpos($event->getResponse()->headers->get('Content-Type'), 'text/html') || $this->requestAnalyzer->getPortalInformation() === null) { return; } $portalUrl = $this->requestAnalyzer->getAttribute('urlExpression'); $analytics = $this->analyticsRepository->findByUrl($portalUrl, $this->requestAnalyzer->getPortalInformation()->getWebspaceKey(), $this->environment); $content = $this->engine->render('SuluWebsiteBundle:Analytics:website.html.twig', ['analytics' => $analytics]); $response = $event->getResponse(); $responseContent = $response->getContent(); $response->setContent(str_replace('</body>', $content . '</body>', $responseContent)); }
/** * {@inheritdoc} */ public function find($id) { return $this->analyticsRepository->findById($id); }