public function checkDomain(MvcEvent $event)
    {
        if ($this->isConsoleRequest()) {
            return null;
        }

        $currentDomain = $this->siteService->getCurrentDomain();

        $site = $this->siteService->getCurrentSite($currentDomain);

        $redirectUrl = $this->domainRedirectService->getSiteNotAvailableRedirectUrl($site);

        if (!$site->isSiteAvailable() && empty($redirectUrl)) {
            $response = new Response();
            $response->setStatusCode(404);
            $event->stopPropagation(true);

            return $response;
        }

        if ($redirectUrl) {
            $response = new Response();
            $response->setStatusCode(302);
            $response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);

            $event->stopPropagation(true);

            return $response;
        }

        $redirectUrl = $this->domainRedirectService->getPrimaryRedirectUrl($site);

        if ($redirectUrl) {
            $response = new Response();
            $response->setStatusCode(302);
            $response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);

            $event->stopPropagation(true);

            return $response;
        }

        return null;
    }
public function checkDomain(MvcEvent $event)
    {
        if ($this->isConsoleRequest()) {
            return null;
        }

        $currentDomain = $this->siteService->getCurrentDomain();

        $site = $this->siteService->getCurrentSite($currentDomain);

        $redirectUrl = $this->domainRedirectService->getSiteNotAvailableRedirectUrl($site);

        if (!$site->isSiteAvailable() && empty($redirectUrl)) {
            $response = new Response();
            $response->setStatusCode(404);
            $event->stopPropagation(true);

            return $response;
        }

        if ($redirectUrl) {
            $response = new Response();
            $response->setStatusCode(302);
            $response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);

            $event->stopPropagation(true);

            return $response;
        }

        $redirectUrl = $this->domainRedirectService->getPrimaryRedirectUrl($site);

        if ($redirectUrl) {
            $response = new Response();
            $response->setStatusCode(302);
            $response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);

            $event->stopPropagation(true);

            return $response;
        }

        return null;
    }
public function checkDomain ( MvcEvent $ event ) { if ( $ this -> isConsoleRequest ( ) ) { return null ; } $ currentDomain = $ this -> siteService -> getCurrentDomain ( ) ; $ site = $ this -> siteService -> getCurrentSite ( $ currentDomain ) ; $ redirectUrl = $ this -> domainRedirectService -> getSiteNotAvailableRedirectUrl ( $ site ) ; if ( ! $ site -> isSiteAvailable ( ) && empty ( $ redirectUrl ) ) { $ response = new Response ( ) ; $ response -> setStatusCode ( 404 ) ; $ event -> stopPropagation ( true ) ; return $ response ; } if ( $ redirectUrl ) { $ response = new Response ( ) ; $ response -> setStatusCode ( 302 ) ; $ response -> getHeaders ( ) -> addHeaderLine ( 'Location' , '//' . $ redirectUrl ) ; $ event -> stopPropagation ( true ) ; return $ response ; } $ redirectUrl = $ this -> domainRedirectService -> getPrimaryRedirectUrl ( $ site ) ; if ( $ redirectUrl ) { $ response = new Response ( ) ; $ response -> setStatusCode ( 302 ) ; $ response -> getHeaders ( ) -> addHeaderLine ( 'Location' , '//' . $ redirectUrl ) ; $ event -> stopPropagation ( true ) ; return $ response ; } return null ; }
Check the domain is a known domain for the CMS.  If not the primary, it will
redirect the user to the primary domain.  Useful for multiple domain sites.

@param MvcEvent $event Zend MVC Event

@return null|Response
Check the domain is a known domain for the CMS . If not the primary it will redirect the user to the primary domain . Useful for multiple domain sites .