findPortalInformationsByWebspaceKeyAndLocale() public method

Returns all portal which matches the given webspace-key and locale.
public findPortalInformationsByWebspaceKeyAndLocale ( string $webspaceKey, string $locale, string $environment ) : PortalInformation[]
$webspaceKey string The webspace-key which the portal should match
$locale string The locale which the portal should match
$environment string The environment in which the url should be searched
return Sulu\Component\Webspace\PortalInformation[]
コード例 #1
0
ファイル: DumpSitemapCommand.php プロジェクト: sulu/sulu
 /**
  * Dump given webspace.
  *
  * @param Webspace $webspace
  */
 private function dumpWebspace(Webspace $webspace)
 {
     foreach ($webspace->getAllLocalizations() as $localization) {
         $this->output->writeln(sprintf(' - %s (%s)', $webspace->getKey(), $localization->getLocale()));
         $this->dumpPortalInformations($this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale($webspace->getKey(), $localization->getLocale(), $this->environment));
     }
 }
コード例 #2
0
ファイル: PreviewRenderer.php プロジェクト: sulu/sulu
 /**
  * {@inheritdoc}
  */
 public function render($object, $id, $webspaceKey, $locale, $partial = false)
 {
     $portalInformations = $this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale($webspaceKey, $locale, $this->environment);
     if (count($portalInformations) === 0) {
         throw new PortalNotFoundException($object, $id, $webspaceKey, $locale);
     }
     if (!$this->routeDefaultsProvider->supports(get_class($object))) {
         throw new RouteDefaultsProviderNotFoundException($object, $id, $webspaceKey, $locale);
     }
     /** @var PortalInformation $portalInformation */
     $portalInformation = reset($portalInformations);
     $webspace = $portalInformation->getWebspace();
     $localization = $webspace->getLocalization($locale);
     $query = [];
     $request = [];
     $cookies = [];
     $currentRequest = $this->requestStack->getCurrentRequest();
     if ($currentRequest !== null) {
         $query = $currentRequest->query->all();
         $request = $currentRequest->request->all();
         $cookies = $currentRequest->cookies->all();
     }
     $attributes = new RequestAttributes(['webspace' => $webspace, 'locale' => $locale, 'localization' => $localization, 'portal' => $portalInformation->getPortal(), 'portalUrl' => $portalInformation->getUrl(), 'resourceLocatorPrefix' => $portalInformation->getPrefix(), 'getParameters' => $query, 'postParameters' => $request, 'analyticsKey' => $this->previewDefaults['analyticsKey'], 'portalInformation' => $portalInformation]);
     $defaults = $this->routeDefaultsProvider->getByEntity(get_class($object), $id, $locale, $object);
     // Controller arguments
     $defaults['object'] = $object;
     $defaults['preview'] = true;
     $defaults['partial'] = $partial;
     $defaults['_sulu'] = $attributes;
     $request = new Request($query, $request, $defaults, $cookies);
     $request->setLocale($locale);
     $this->eventDispatcher->dispatch(Events::PRE_RENDER, new PreRenderEvent($attributes));
     try {
         $response = $this->handle($request);
     } catch (\Twig_Error $e) {
         throw new TwigException($e, $object, $id, $webspace, $locale);
     } catch (\InvalidArgumentException $e) {
         throw new TemplateNotFoundException($e, $object, $id, $webspace, $locale);
     } catch (\Exception $e) {
         throw new UnexpectedException($e, $object, $id, $webspace, $locale);
     }
     return $response->getContent();
 }
コード例 #3
0
 /**
  * Matches given url to portal-information.
  *
  * @param string $url
  * @param PortalInformation $portalInformation
  * @param Request $request
  *
  * @return RequestAttributes|void
  */
 private function matchCustomUrl($url, PortalInformation $portalInformation, Request $request)
 {
     $webspace = $portalInformation->getWebspace();
     $routeDocument = $this->customUrlManager->findRouteByUrl($url, $webspace->getKey());
     if (!$routeDocument) {
         return [];
     } elseif ($routeDocument->isHistory()) {
         // redirect happen => no portal is needed
         return ['customUrlRoute' => $routeDocument];
     }
     $customUrlDocument = $this->customUrlManager->findByUrl($url, $webspace->getKey(), $routeDocument->getTargetDocument()->getTargetLocale());
     if ($customUrlDocument === null || $customUrlDocument->isPublished() === false || $customUrlDocument->getTargetDocument() === null || $customUrlDocument->getTargetDocument()->getWorkflowStage() !== WorkflowStage::PUBLISHED) {
         // error happen because this custom-url is not published => no portal is needed
         return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
     }
     $localization = $this->parse($customUrlDocument->getTargetLocale());
     $portalInformations = $this->webspaceManager->findPortalInformationsByWebspaceKeyAndLocale($portalInformation->getWebspace()->getKey(), $localization->getLocalization(), $this->environment);
     if (0 === count($portalInformations)) {
         return ['customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument];
     }
     return ['portalInformation' => $portalInformation, 'localization' => $localization, 'customUrlRoute' => $routeDocument, 'customUrl' => $customUrlDocument, 'urlExpression' => $this->generator->generate($customUrlDocument->getBaseDomain(), $customUrlDocument->getDomainParts())];
 }