src/Sulu/Bundle/CustomUrlBundle/Request/CustomUrlRequestProcessor.php
private function matchCustomUrl($url, PortalInformation $portalInformation, Request $request)
    {
        $webspace = $portalInformation->getWebspace();
        $routeDocument = $this->customUrlManager->findRouteByUrl(
            rawurldecode($url),
            $webspace->getKey()
        );

        if (!$routeDocument) {
            return [];
        } elseif ($routeDocument->isHistory()) {
            // redirect happen => no portal is needed
            return ['customUrlRoute' => $routeDocument];
        }

        $customUrlDocument = $this->customUrlManager->findByUrl(
            rawurldecode($url),
            $webspace->getKey(),
            $routeDocument->getTargetDocument()->getTargetLocale()
        );

        if (null === $customUrlDocument
            || false === $customUrlDocument->isPublished()
            || null === $customUrlDocument->getTargetDocument()
            || WorkflowStage::PUBLISHED !== $customUrlDocument->getTargetDocument()->getWorkflowStage()
        ) {
            // error happen because this custom-url is not published => no portal is needed
            return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
        }

        $localization = Localization::createFromString($customUrlDocument->getTargetLocale());

        $portalInformations = $this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale(
            $portalInformation->getWebspace()->getKey(),
            $localization->getLocale(),
            $this->environment
        );

        if (0 === count($portalInformations)) {
            return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
        }

        return [
            'portalInformation' => $portalInformation,
            'localization' => $localization,
            'locale' => $localization->getLocale(),
            'customUrlRoute' => $routeDocument,
            'customUrl' => $customUrlDocument,
            'urlExpression' => $this->generator->generate(
                $customUrlDocument->getBaseDomain(),
                $customUrlDocument->getDomainParts()
            ),
        ];
    }
private function matchCustomUrl($url, PortalInformation $portalInformation, Request $request)
    {
        $webspace = $portalInformation->getWebspace();
        $routeDocument = $this->customUrlManager->findRouteByUrl(
            rawurldecode($url),
            $webspace->getKey()
        );

        if (!$routeDocument) {
            return [];
        } elseif ($routeDocument->isHistory()) {
            // redirect happen => no portal is needed
            return ['customUrlRoute' => $routeDocument];
        }

        $customUrlDocument = $this->customUrlManager->findByUrl(
            rawurldecode($url),
            $webspace->getKey(),
            $routeDocument->getTargetDocument()->getTargetLocale()
        );

        if (null === $customUrlDocument
            || false === $customUrlDocument->isPublished()
            || null === $customUrlDocument->getTargetDocument()
            || WorkflowStage::PUBLISHED !== $customUrlDocument->getTargetDocument()->getWorkflowStage()
        ) {
            // error happen because this custom-url is not published => no portal is needed
            return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
        }

        $localization = Localization::createFromString($customUrlDocument->getTargetLocale());

        $portalInformations = $this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale(
            $portalInformation->getWebspace()->getKey(),
            $localization->getLocale(),
            $this->environment
        );

        if (0 === count($portalInformations)) {
            return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
        }

        return [
            'portalInformation' => $portalInformation,
            'localization' => $localization,
            'locale' => $localization->getLocale(),
            'customUrlRoute' => $routeDocument,
            'customUrl' => $customUrlDocument,
            'urlExpression' => $this->generator->generate(
                $customUrlDocument->getBaseDomain(),
                $customUrlDocument->getDomainParts()
            ),
        ];
    }
private function matchCustomUrl ( $ url , PortalInformation $ portalInformation , Request $ request ) { $ webspace = $ portalInformation -> getWebspace ( ) ; $ routeDocument = $ this -> customUrlManager -> findRouteByUrl ( rawurldecode ( $ url ) , $ webspace -> getKey ( ) ) ; if ( ! $ routeDocument ) { return [ ] ; } elseif ( $ routeDocument -> isHistory ( ) ) { // redirect happen => no portal is needed return [ 'customUrlRoute' => $ routeDocument ] ; } $ customUrlDocument = $ this -> customUrlManager -> findByUrl ( rawurldecode ( $ url ) , $ webspace -> getKey ( ) , $ routeDocument -> getTargetDocument ( ) -> getTargetLocale ( ) ) ; if ( null === $ customUrlDocument || false === $ customUrlDocument -> isPublished ( ) || null === $ customUrlDocument -> getTargetDocument ( ) || WorkflowStage :: PUBLISHED !== $ customUrlDocument -> getTargetDocument ( ) -> getWorkflowStage ( ) ) { // error happen because this custom-url is not published => no portal is needed return [ 'customUrlRoute' => $ routeDocument , 'customUrl' => $ customUrlDocument ] ; } $ localization = Localization :: createFromString ( $ customUrlDocument -> getTargetLocale ( ) ) ; $ portalInformations = $ this -> webspaceManager -> findPortalInformationsByWebspaceKeyAndLocale ( $ portalInformation -> getWebspace ( ) -> getKey ( ) , $ localization -> getLocale ( ) , $ this -> environment ) ; if ( 0 === count ( $ portalInformations ) ) { return [ 'customUrlRoute' => $ routeDocument , 'customUrl' => $ customUrlDocument ] ; } return [ 'portalInformation' => $ portalInformation , 'localization' => $ localization , 'locale' => $ localization -> getLocale ( ) , 'customUrlRoute' => $ routeDocument , 'customUrl' => $ customUrlDocument , 'urlExpression' => $ this -> generator -> generate ( $ customUrlDocument -> getBaseDomain ( ) , $ customUrlDocument -> getDomainParts ( ) ) , ] ; }
Matches given url to portal-information.

@param string $url
@param PortalInformation $portalInformation
@param Request $request

@return array
Matches given url to portal - information .