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 testAddLink()
 {
     $url = new Sitemap\Url\GoogleMultilangUrlDecorator(new Sitemap\Url\UrlConcrete('http://acme.com'));
     $url->addLink('http://fr.acme.com/', 'fr');
     $xml = $url->toXml();
     $this->assertTrue('<url><loc>http://acme.com</loc><xhtml:link rel="alternate" hreflang="fr" href="http://fr.acme.com/" /></url>' == $xml);
 }