/**
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $response = $event->getResponse();
     if ($response instanceof RedirectResponse) {
         return;
     }
     $request = $event->getRequest();
     if ($request->isXmlHttpRequest()) {
         return;
     }
     if (!$this->isAdminRoute($request->getRequestUri())) {
         return;
     }
     if ($request->getHost() !== $this->domainConfiguration->getHost()) {
         // Add flash message for admin pages
         $this->session->getFlashBag()->add('warning', 'multi_domain.host_override_active');
     }
 }
 private function initRoutes()
 {
     $redirects = $this->redirectRepository->findAll();
     $domain = $this->domainConfiguration->getHost();
     /** @var Redirect $redirect */
     foreach ($redirects as $redirect) {
         // Only add the route when the domain matches or the domain is empty
         if ($redirect->getDomain() == $domain || !$redirect->getDomain()) {
             $this->routeCollection->add('_redirect_route_' . $redirect->getId(), new Route($redirect->getOrigin(), array('_controller' => 'FrameworkBundle:Redirect:urlRedirect', 'path' => $redirect->getTarget(), 'permanent' => $redirect->isPermanent())));
         }
     }
 }
Example #3
0
 /**
  * @return string
  */
 protected function getHost()
 {
     return $this->domainConfiguration->getHost();
 }
 /**
  * @return array
  */
 public function getCurrentHost()
 {
     return $this->domainConfiguration->getHost();
 }