/** * {@inheritdoc} */ public function getUrls(Webspace $webspace, $environment) { $urls = []; foreach ($webspace->getPortals() as $portal) { $urls = array_merge($urls, $portal->getEnvironment($environment)->getUrls()); } return $urls; }
/** * Validate that all localizations are used in the portals. * * @throws Exception\PortalDefaultLocalizationNotFoundException * @throws Exception\InvalidPortalDefaultLocalizationException */ protected function validateLocalizations() { $locales = array_unique(array_map(function (Localization $localization) { return $localization->getLocale(Localization::UNDERSCORE); }, $this->webspace->getAllLocalizations())); $portalLocales = []; foreach ($this->webspace->getPortals() as $portal) { $portalLocales = array_merge($portalLocales, array_map(function (Localization $localization) { return $localization->getLocale(Localization::UNDERSCORE); }, $portal->getLocalizations())); } $portalLocales = array_unique($portalLocales); if (array_diff($locales, $portalLocales) || array_diff($portalLocales, $locales)) { throw new WebspaceLocalizationNotUsedException($this->webspace); } }
/** * Validate portal localization. * * @throws Exception\PortalDefaultLocalizationNotFoundException * @throws Exception\InvalidPortalDefaultLocalizationException */ private function validateDefaultPortalLocalization() { // check all portal localizations foreach ($this->webspace->getPortals() as $portal) { try { if (!$this->validateDefaultLocalization($portal->getLocalizations())) { // try to load the webspace localizations before throwing an exception if (!$this->loadPortalLocalizationDefaultFromWebspace($portal)) { throw new PortalDefaultLocalizationNotFoundException($this->webspace, $portal); } } } catch (InvalidDefaultLocalizationException $ex) { throw new InvalidPortalDefaultLocalizationException($this->webspace, $portal); } } }
/** * Extract custom-url and add them to serialization. * * @param Webspace $webspace * @param Context $context * @param JsonSerializationVisitor $visitor */ private function appendCustomUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $customUrls = []; foreach ($webspace->getPortals() as $portal) { $customUrls = array_merge($customUrls, $this->getCustomUrlsForEnvironment($portal, $portal->getEnvironment($this->environment), $context)); } $customUrls = $context->accept($customUrls); $visitor->addData('customUrls', $customUrls); }
/** * @param Webspace $webspace */ private function buildPortals(Webspace $webspace) { foreach ($webspace->getPortals() as $portal) { $this->portals[] = $portal; $this->buildEnvironments($portal); } }