setLanguage() public method

Sets the language to which this url leads.
public setLanguage ( string $language )
$language string
Example #1
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);
     }
 }
Example #2
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);
 }