getPortalInformation() public method

Returns portal-information of request.
public getPortalInformation ( ) : PortalInformation
return Sulu\Component\Webspace\PortalInformation
Example #1
0
 /**
  * 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));
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function onRequest(GetResponseEvent $event)
 {
     $context = $this->router->getContext();
     $portalInformation = $this->requestAnalyzer->getPortalInformation();
     if ($portalInformation) {
         if (!$context->hasParameter('prefix')) {
             $context->setParameter('prefix', $portalInformation->getPrefix());
         }
         if (!$context->hasParameter('host')) {
             $context->setParameter('host', $portalInformation->getHost());
         }
     }
 }