Inheritance: implements Sulu\Component\Util\ArrayableInterface
Ejemplo n.º 1
0
 /**
  * Builds the URLs for the portal, which are not a redirect.
  *
  * @param Portal      $portal
  * @param Environment $environment
  * @param $url
  * @param $segments
  * @param $urlAddress
  * @param $urlAnalyticsKey
  */
 private function buildUrls(Portal $portal, Environment $environment, Url $url, $segments, $urlAddress, $urlAnalyticsKey)
 {
     if ($url->getLanguage()) {
         $language = $url->getLanguage();
         $country = $url->getCountry();
         $locale = $language . ($country ? '_' . $country : '');
         $this->buildUrlFullMatch($portal, $environment, $segments, [], $urlAddress, $portal->getLocalization($locale), $urlAnalyticsKey);
     } else {
         // create all the urls for every localization/segment combination
         foreach ($portal->getLocalizations() as $localization) {
             $language = $url->getLanguage() ? $url->getLanguage() : $localization->getLanguage();
             $country = $url->getCountry() ? $url->getCountry() : $localization->getCountry();
             $replacers = [self::REPLACER_LANGUAGE => $language, self::REPLACER_COUNTRY => $country, self::REPLACER_LOCALIZATION => $localization->getLocalization('-')];
             $this->buildUrlFullMatch($portal, $environment, $segments, $replacers, $urlAddress, $localization, $urlAnalyticsKey);
         }
         $this->buildUrlPartialMatch($portal, $environment, $urlAddress, $urlAnalyticsKey);
     }
 }
Ejemplo n.º 2
0
 /**
  * Generates the URLs for the given environment.
  *
  * @param \DOMNode $environmentNode
  * @param Environment $environment
  *
  * @throws Exception\InvalidUrlDefinitionException
  */
 protected function generateUrls(\DOMNode $environmentNode, Environment $environment)
 {
     foreach ($this->xpath->query('x:urls/x:url', $environmentNode) as $urlNode) {
         // check if the url is valid, and throw an exception otherwise
         if (!$this->checkUrlNode($urlNode)) {
             throw new InvalidUrlDefinitionException($this->webspace, $urlNode->nodeValue);
         }
         /** @var \DOMNode $urlNode */
         $url = new Url();
         $url->setUrl(rtrim($urlNode->nodeValue, '/'));
         // set optional nodes
         $url->setLanguage($this->getOptionalNodeAttribute($urlNode, 'language'));
         $url->setCountry($this->getOptionalNodeAttribute($urlNode, 'country'));
         $url->setSegment($this->getOptionalNodeAttribute($urlNode, 'segment'));
         $url->setRedirect($this->getOptionalNodeAttribute($urlNode, 'redirect'));
         $url->setMain($this->getOptionalNodeAttribute($urlNode, 'main', false));
         $url->setAnalyticsKey($this->getOptionalNodeAttribute($urlNode, 'analytics-key'));
         $environment->addUrl($url);
     }
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     $webspaces = [];
     $portals = [];
     $portalInformations = ['prod' => [], 'dev' => []];
     $this->webspaceCollection = new WebspaceCollection();
     // first portal
     $portal = new Portal();
     $portal->setName('Portal1');
     $portal->setKey('portal1');
     $theme = new Theme();
     $theme->setKey('portal1theme');
     $environment = new Environment();
     $url = new Url();
     $url->setUrl('www.portal1.com');
     $url->setLanguage('en');
     $url->setCountry('us');
     $environment->addUrl($url);
     $environment->setType('prod');
     $url = new Url();
     $url->setUrl('portal1.com');
     $url->setRedirect('www.portal1.com');
     $environment->addUrl($url);
     $portal->addEnvironment($environment);
     $localizationEnUs = new Localization();
     $localizationEnUs->setCountry('us');
     $localizationEnUs->setLanguage('en');
     $localizationEnUs->setShadow('auto');
     $localizationEnUs->setDefault(true);
     $localizationEnCa = new Localization();
     $localizationEnCa->setCountry('ca');
     $localizationEnCa->setLanguage('en');
     $localizationEnCa->setDefault(false);
     $localizationEnUs->addChild($localizationEnCa);
     $localizationFrCa = new Localization();
     $localizationFrCa->setCountry('ca');
     $localizationFrCa->setLanguage('fr');
     $localizationFrCa->setDefault(false);
     $portal->addLocalization($localizationEnUs);
     $portal->addLocalization($localizationEnCa);
     $portal->addLocalization($localizationFrCa);
     $portal->setDefaultLocalization($localizationEnUs);
     $portal->setResourceLocatorStrategy('tree');
     $webspace = new Webspace();
     $webspace->addLocalization($localizationEnUs);
     $webspace->addLocalization($localizationFrCa);
     $segmentSummer = new Segment();
     $segmentSummer->setName('Summer');
     $segmentSummer->setKey('s');
     $segmentSummer->setDefault(true);
     $segmentWinter = new Segment();
     $segmentWinter->setName('Winter');
     $segmentWinter->setKey('w');
     $segmentWinter->setDefault(false);
     $webspace->addSegment($segmentSummer);
     $webspace->addSegment($segmentWinter);
     $webspace->setTheme($theme);
     $webspace->addPortal($portal);
     $webspace->setKey('default');
     $webspace->setName('Default');
     $webspace->addPortal($portal);
     $webspace->setNavigation(new Navigation([new NavigationContext('main', [])]));
     $portals[] = $portal;
     $webspaces[] = $webspace;
     $portalInformations['prod']['www.portal1.com'] = new PortalInformation(RequestAnalyzerInterface::MATCH_TYPE_FULL, $webspace, $portal, $localizationEnUs, 'www.portal1.com', $segmentSummer);
     $portalInformations['dev']['portal1.lo'] = new PortalInformation(RequestAnalyzerInterface::MATCH_TYPE_FULL, $webspace, $portal, $localizationEnUs, 'portal1.lo', $segmentSummer);
     $this->webspaceCollection->setWebspaces($webspaces);
     $this->webspaceCollection->setPortals($portals);
     $this->webspaceCollection->setPortalInformations($portalInformations);
 }