public function SimplesitemapController::getSitemap in Simple XML sitemap 8.3
Same name and namespace in other branches
- 8.2 src/Controller/SimplesitemapController.php \Drupal\simple_sitemap\Controller\SimplesitemapController::getSitemap()
- 4.x src/Controller/SimpleSitemapController.php \Drupal\simple_sitemap\Controller\SimpleSitemapController::getSitemap()
Returns the whole sitemap variant, its requested chunk, or its sitemap index file. Caches the response in case of expected output, prevents caching otherwise.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
string $variant: Optional name of sitemap variant. @see SimplesitemapManager::getSitemapVariants()
Return value
\Symfony\Component\HttpFoundation\Response|false Returns an XML response.
Throws
1 string reference to 'SimplesitemapController::getSitemap'
File
- src/
Controller/ SimplesitemapController.php, line 58
Class
- SimplesitemapController
- Class SimplesitemapController @package Drupal\simple_sitemap\Controller
Namespace
Drupal\simple_sitemap\ControllerCode
public function getSitemap(Request $request, $variant = NULL) {
$output = $this->generator
->setVariants($variant)
->getSitemap($request->query
->getInt('page'));
if (!$output) {
throw new NotFoundHttpException();
}
return new Response($output, Response::HTTP_OK, [
'Content-type' => 'application/xml; charset=utf-8',
'X-Robots-Tag' => 'noindex, follow',
]);
}