コード例 #1
0
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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));
 }