/** * @param SitemapPopulateEvent $event * @throws \InvalidArgumentException */ private function addUrlsFromRoutes(SitemapPopulateEvent $event) { $collection = $this->router->getRouteCollection(); foreach ($collection->all() as $name => $route) { $options = $this->getOptions($name, $route); if ($options) { $event->getGenerator()->addUrl($this->getUrlConcrete($name, $options), $event->getSection() ? $event->getSection() : 'default'); } } }
public function populateSitemap(SitemapPopulateEvent $event) { $section = $event->getSection(); if (is_null($section) || $section == 'cms') { foreach ($this->locales as $locale) { $nodeRepository = $this->entityManager->getRepository('AlpixelCMSBundle:Node'); $pages = $nodeRepository->findAllWithLocale($locale); foreach ($pages as $page) { $hasController = true; foreach ($this->contentTypes as $contentType) { if (get_class($page) == $contentType['class'] && $contentType['controller'] === null) { $hasController = false; } } if ($hasController === false) { continue; } $url = $this->router->generate('alpixel_cms', ['slug' => $page->getSlug(), '_locale' => $page->getLocale()], UrlGeneratorInterface::ABSOLUTE_URL); $url = new UrlConcrete($url, $page->getDateUpdated(), UrlConcrete::CHANGEFREQ_MONTHLY, 0.7); $urlLang = new GoogleMultilangUrlDecorator($url); $translations = $nodeRepository->findTranslations($page); foreach ($translations as $translation) { if ($locale !== $translation->getLocale()) { $url = $this->router->generate('alpixel_cms', ['slug' => $translation->getSlug(), '_locale' => $translation->getLocale()], UrlGeneratorInterface::ABSOLUTE_URL); $urlLang->addLink($url, $translation->getLocale()); } } $event->getGenerator()->addUrl($urlLang, 'cms.' . $locale); } } } }
public function populateSitemap(SitemapPopulateEvent $event) { $section = $event->getSection(); if (is_null($section) || $section == 'default') { //get absolute homepage url $url = $this->router->generate('blog_index', array(), UrlGeneratorInterface::ABSOLUTE_URL); //add homepage url to the urlset named default $event->getGenerator()->addUrl(new UrlConcrete($url, new \DateTime(), UrlConcrete::CHANGEFREQ_HOURLY, 1), 'default'); } }
public function populateSitemap(SitemapPopulateEvent $event) { $section = $event->getSection(); if (is_null($section) || $section == 'default') { //get absolute homepage url $urls = array('frontend_homepage' => $this->router->generate('frontend_homepage', array(), UrlGeneratorInterface::ABSOLUTE_URL), 'frontend_feedback' => $this->router->generate('frontend_feedback', array(), UrlGeneratorInterface::ABSOLUTE_URL), 'frontend_work_index' => $this->router->generate('frontend_work_index', array(), UrlGeneratorInterface::ABSOLUTE_URL), 'frontend_page_contacts' => $this->router->generate('frontend_page_contacts', array(), UrlGeneratorInterface::ABSOLUTE_URL)); foreach ($urls as $url) { $event->getGenerator()->addUrl(new UrlConcrete($url, new \DateTime(), UrlConcrete::CHANGEFREQ_HOURLY, 1), 'default'); } } }
public function populateSitemap(SitemapPopulateEvent $event) { $section = $event->getSection(); if (is_null($section) || $section == 'default') { //get absolute homepage url $url = $this->router->generate('homepage', array(), true); $urlBase = new Url\GoogleMultilangUrlDecorator(new Url\UrlConcrete($url, new \DateTime(), UrlConcrete::CHANGEFREQ_MONTHLY, 1)); //add homepage url to the urlset named default $event->getGenerator()->addUrl($urlBase, 'default'); } }
/** * Populate the sitemap. * * @param SitemapPopulateEvent $event */ public function populateSitemap(SitemapPopulateEvent $event) { $section = $event->getSection(); if (is_null($section) || $section == 'default') { $contentRepository = $this->em->getRepository('OpiferCmsBundle:Content'); $content = $contentRepository->findAll(); foreach ($content as $item) { if ($item->isPrivate() || !$item->isIndexable()) { continue; } // Get absolute content url $url = $this->router->generate('_content', ['slug' => $item->getSlug()], true); // Add the url to the urlset named default $event->getGenerator()->addUrl(new UrlConcrete($url, new \DateTime(), UrlConcrete::CHANGEFREQ_HOURLY, 1), 'default'); } } }