public function populate(Sitemap $sitemap) { foreach ($this->options['routes'] as $route) { $route = array_merge($this->defaultRoute, $route); $url = new Url(); $url->setLoc($this->router->generate($route['name'], $route['params'])); $url->setChangefreq($route['changefreq'] ?: $this->options['changefreq']); $url->setLastmod($route['lastmod'] ?: $this->options['lastmod']); $url->setPriority($route['priority'] ?: $this->options['priority']); $sitemap->add($url); } }
protected function resultToUrl($result) { $url = new Url(); $url->setLoc($this->getResultLoc($result)); if ($this->options['priority'] !== null) { $url->setPriority($this->options['priority']); } if ($this->options['changefreq'] !== null) { $url->setChangefreq($this->options['changefreq']); } if ($this->options['lastmod'] !== null) { $url->setLastmod($this->getColumnValue($result, $this->options['lastmod'])); } return $url; }
public function populate(Sitemap $sitemap) { $url = new Url(); $url->setLoc('http://www.google.fr'); $url->setChangefreq(Url::CHANGEFREQ_NEVER); $url->setLastmod('2012-12-19 02:28'); $video = new Video(); $video->setThumbnailLoc('http://www.example.com/thumbs/123.jpg'); $video->setTitle('Grilling steaks for summer'); $video->setDescription('Alkis shows you how to get perfectly done steaks every time'); $url->addVideo($video); $sitemap->add($url); $url = new Url(); $url->setLoc('http://github.com'); $url->setChangefreq(Url::CHANGEFREQ_ALWAYS); $url->setPriority(0.2); $sitemap->add($url); }
/** * @dataProvider invalidPriorityProvider * @expectedException DomainException */ public function testInvalidPriority($priority) { $url = new Url(); $url->setPriority($priority); }
public function testFormatUrlWithFullImage() { $url = new Url(); $url->setLoc('http://www.google.fr/?s=joe"'); $url->setPriority(0.2); $url->setChangefreq(Url::CHANGEFREQ_NEVER); $image = new Image(); $image->setLoc('http://www.example.com/thumbs/123.jpg'); $image->setTitle('Grilling steaks for "summer"'); $image->setCaption('Some caption'); $image->setLicense('http://opensource.org/licenses/mit-license.php'); $image->setGeoLocation('France'); $url->addImage($image); $this->assertEquals("<url>\n" . "\t<loc>http://www.google.fr/?s=joe"</loc>\n" . "\t<changefreq>never</changefreq>\n" . "\t<priority>0.2</priority>\n" . "\t<image:image>\n" . "\t\t<image:loc>http://www.example.com/thumbs/123.jpg</image:loc>\n" . "\t\t<image:caption>Some caption</image:caption>\n" . "\t\t<image:geo_location>France</image:geo_location>\n" . "\t\t<image:title>Grilling steaks for "summer"</image:title>\n" . "\t\t<image:license>http://opensource.org/licenses/mit-license.php</image:license>\n" . "\t</image:image>\n" . "</url>\n", $this->formatter->formatUrl($url)); }