Inheritance: implements Thepixeldeveloper\Sitemap\OutputInterface
Ejemplo n.º 1
0
 /**
  * @return Urlset
  */
 protected function collectSitemapItems()
 {
     $urlSet = new Urlset();
     foreach ($this->sitemapRegistrar->getAvailableModules() as $module) {
         foreach ($module->getUrls() as $sitemapItem) {
             $urlSet->addUrl($sitemapItem);
         }
     }
     return $urlSet;
 }
Ejemplo n.º 2
0
 /**
  * @param Urlset $urlSet
  */
 private function addTags(Urlset $urlSet)
 {
     foreach ($this->catalogueRepository->loadAllTags() as $tag) {
         $url = new Url(htmlspecialchars($tag->url()));
         $url->setLastMod($tag->updated_at->toW3cString());
         $url->setChangeFreq('monthly');
         $url->setPriority(0.3);
         $urlSet->addUrl($url);
     }
 }
Ejemplo n.º 3
0
<?php

require_once __DIR__ . '/../bootstrap.php';
use Thepixeldeveloper\Sitemap\Output;
use Thepixeldeveloper\Sitemap\Url;
use Thepixeldeveloper\Sitemap\Urlset;
/**
 * Helper function to build each sitemap
 *
 * @param array  $entries
 * @param string $domain
 * @return boolean
 */
$buildSitemap = function (array $entries, $domain, $folder) {
    $urlSet = new Urlset();
    foreach ($entries as $path => $entry) {
        $url = new Url("{$domain}{$path}");
        // todo better detection of domain by env
        $url->setLastMod($entry['lastmod']);
        // todo check if exists
        $url->setChangeFreq($entry['changefreq']);
        // todo check if exists
        $url->setPriority($entry['priority']);
        // todo check if exists
        $urlSet->addUrl($url);
    }
    $output = new Output();
    $output->setIndentString('  ');
    // change indentation from 4 to 2 spaces
    $tempSitemap = __DIR__ . "/../../web/public/{$folder}/sitemap-new.xml";
    $finalSitemap = __DIR__ . "/../../web/public/{$folder}/sitemap.xml";