src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php
private function createPortalInformation($object, $id, $webspaceKey, $locale)
    {
        $webspace = $this->webspaceManager->findWebspaceByKey($webspaceKey);
        $domain = $this->requestStack->getCurrentRequest()->getHost();

        if (!$webspace) {
            throw new WebspaceNotFoundException($object, $id, $webspaceKey, $locale);
        }

        $webspace = clone $webspace;
        $localization = $webspace->getLocalization($locale);

        if (!$localization) {
            throw new WebspaceLocalizationNotFoundException($object, $id, $webspaceKey, $locale);
        }

        $localization = clone $localization;
        $localization->setXDefault(true);
        $portal = new Portal();
        $portal->setName($webspace->getName());
        $portal->setKey($webspace->getKey());
        $portal->setWebspace($webspace);
        $portal->setXDefaultLocalization($localization);
        $portal->setLocalizations([$localization]);
        $portal->setDefaultLocalization($localization);
        $environment = new Environment();
        $url = new Url($domain, $this->environment);
        $environment->setUrls([$url]);
        $portal->setEnvironments([$environment]);
        $webspace->setPortals([$portal]);

        return new PortalInformation(RequestAnalyzer::MATCH_TYPE_FULL, $webspace, $portal, $localization, $domain);
    }
private function createPortalInformation($object, $id, $webspaceKey, $locale)
    {
        $webspace = $this->webspaceManager->findWebspaceByKey($webspaceKey);
        $domain = $this->requestStack->getCurrentRequest()->getHost();

        if (!$webspace) {
            throw new WebspaceNotFoundException($object, $id, $webspaceKey, $locale);
        }

        $webspace = clone $webspace;
        $localization = $webspace->getLocalization($locale);

        if (!$localization) {
            throw new WebspaceLocalizationNotFoundException($object, $id, $webspaceKey, $locale);
        }

        $localization = clone $localization;
        $localization->setXDefault(true);
        $portal = new Portal();
        $portal->setName($webspace->getName());
        $portal->setKey($webspace->getKey());
        $portal->setWebspace($webspace);
        $portal->setXDefaultLocalization($localization);
        $portal->setLocalizations([$localization]);
        $portal->setDefaultLocalization($localization);
        $environment = new Environment();
        $url = new Url($domain, $this->environment);
        $environment->setUrls([$url]);
        $portal->setEnvironments([$environment]);
        $webspace->setPortals([$portal]);

        return new PortalInformation(RequestAnalyzer::MATCH_TYPE_FULL, $webspace, $portal, $localization, $domain);
    }
private function createPortalInformation ( $ object , $ id , $ webspaceKey , $ locale ) { $ webspace = $ this -> webspaceManager -> findWebspaceByKey ( $ webspaceKey ) ; $ domain = $ this -> requestStack -> getCurrentRequest ( ) -> getHost ( ) ; if ( ! $ webspace ) { throw new WebspaceNotFoundException ( $ object , $ id , $ webspaceKey , $ locale ) ; } $ webspace = clone $ webspace ; $ localization = $ webspace -> getLocalization ( $ locale ) ; if ( ! $ localization ) { throw new WebspaceLocalizationNotFoundException ( $ object , $ id , $ webspaceKey , $ locale ) ; } $ localization = clone $ localization ; $ localization -> setXDefault ( true ) ; $ portal = new Portal ( ) ; $ portal -> setName ( $ webspace -> getName ( ) ) ; $ portal -> setKey ( $ webspace -> getKey ( ) ) ; $ portal -> setWebspace ( $ webspace ) ; $ portal -> setXDefaultLocalization ( $ localization ) ; $ portal -> setLocalizations ( [ $ localization ] ) ; $ portal -> setDefaultLocalization ( $ localization ) ; $ environment = new Environment ( ) ; $ url = new Url ( $ domain , $ this -> environment ) ; $ environment -> setUrls ( [ $ url ] ) ; $ portal -> setEnvironments ( [ $ environment ] ) ; $ webspace -> setPortals ( [ $ portal ] ) ; return new PortalInformation ( RequestAnalyzer :: MATCH_TYPE_FULL , $ webspace , $ portal , $ localization , $ domain ) ; }
This creates a new portal information based on the given information. This is necessary because it is possible
that a webspace defines a language, which is not used in any portal. For this case we have to define our own
fake PortalInformation object.

@param object $object
@param int $id
@param string $webspaceKey
@param string $locale

@return PortalInformation

@throws WebspaceLocalizationNotFoundException
@throws WebspaceNotFoundException
This creates a new portal information based on the given information . This is necessary because it is possible that a webspace defines a language which is not used in any portal . For this case we have to define our own fake PortalInformation object .