/** * 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); } }