protected function formatSitemapIndexBody(SitemapIndex $sitemapIndex) { $buffer = "\t" . '<loc>' . $this->escape($sitemapIndex->getLoc()) . '</loc>' . "\n"; if ($sitemapIndex->getLastmod() !== null) { $buffer .= "\t" . '<lastmod>' . $this->escape($sitemapIndex->getLastmod()) . '</lastmod>' . "\n"; } return $buffer; }
protected function createSitemapIndex() { $sitemapIndexFilename = $this->getSitemapIndexFilename($this->originalFilename); $sitemapIndex = new SitemapIndex(); $loc = DIRECTORY_SEPARATOR . basename($sitemapIndexFilename); if ($this->baseHostSitemap !== null) { $sitemapIndex->setLoc($this->baseHostSitemap . $loc); } $sitemapIndex->setLastMod(new \DateTime()); return $sitemapIndex; }
public function testFormatSitemapIndexNoLastMod() { $sitemapIndex = new SitemapIndex(); $sitemapIndex->setLoc('http://www.example.com/sitemap-1.xml'); $this->assertEquals("<sitemap>\n" . "\t<loc>http://www.example.com/sitemap-1.xml</loc>\n" . "</sitemap>\n", $this->formatter->formatSitemapIndex($sitemapIndex)); }