public function testProvider() { $urlInformations = $this->provider->getUrlInformation(); $this->assertCount(1, $urlInformations); $urlInformation = reset($urlInformations); $this->assertInstanceof('Symfony\\Cmf\\Bundle\\SeoBundle\\Model\\UrlInformation', $urlInformation); $this->assertEquals('http://symfony.com', $urlInformation->getLocation()); }
/** * @param string $_format The format of the sitemap. * @param string $sitemap The sitemap to show. * * @return Response */ public function indexAction($_format, $sitemap) { if (!isset($this->configurations[$sitemap])) { throw new NotFoundHttpException(sprintf('Unknown sitemap "%s"', $sitemap)); } $templates = $this->configurations[$sitemap]['templates']; $supportedFormats = array_merge(array('json'), array_keys($templates)); if (!in_array($_format, $supportedFormats)) { $text = sprintf('Unknown format %s, use one of %s.', $_format, implode(', ', $supportedFormats)); return new Response($text, 406); } $urlInformation = $this->sitemapProvider->getUrlInformation($sitemap); if (isset($templates[$_format])) { return new Response($this->templating->render($templates[$_format], array('urls' => $urlInformation))); } return $this->createJsonResponse($urlInformation); }