Пример #1
0
 /**
  * @param string $_format The format of the sitemap.
  *
  * @return Response
  */
 public function indexAction($_format)
 {
     $supportedFormats = array_merge(array('json'), array_keys($this->templates));
     if (!in_array($_format, $supportedFormats)) {
         $text = sprintf('Unknown format %s, use one of %s.', $_format, implode(', ', $supportedFormats));
         return new Response($text, 406);
     }
     $urls = $this->urlProvider->getUrlInformation();
     if (isset($this->templates[$_format])) {
         return new Response($this->templating->render($this->templates[$_format], array('urls' => $urls)));
     }
     return $this->createJsonResponse($urls);
 }
 private function createRoutes()
 {
     $urls = array();
     $simpleUrl = new UrlInformation();
     $simpleUrl->setLocation('http://www.test-domain.de')->setChangeFrequency('always')->setLabel('Test label')->setPriority(0.85)->setLastModification(new \DateTime('2014-11-06', new \DateTimeZone('Europe/Berlin')));
     $urlWithAlternateLocale = new UrlInformation();
     $urlWithAlternateLocale->setLocation('http://www.test-alternate-locale.de')->setChangeFrequency('never')->setLabel('Test alternate locale')->setPriority(0.85)->setLastModification(new \DateTime('2014-11-07', new \DateTimeZone('Europe/Berlin')));
     $alternateLocale = new AlternateLocale('http://www.test-alternate-locale.com', 'en');
     $urlWithAlternateLocale->addAlternateLocale($alternateLocale);
     $urls[] = $urlWithAlternateLocale;
     $urls[] = $simpleUrl;
     $this->provider->expects($this->any())->method('getUrlInformation')->will($this->returnValue($urls));
 }