public function SimpleSitemapController::getSitemap in Simple XML sitemap 4.x
Same name and namespace in other branches
- 8.3 src/Controller/SimplesitemapController.php \Drupal\simple_sitemap\Controller\SimplesitemapController::getSitemap()
- 8.2 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|null $variant: Optional name of sitemap variant.
Return value
\Symfony\Component\HttpFoundation\Response Returns an XML response.
Throws
1 string reference to 'SimpleSitemapController::getSitemap'
File
- src/
Controller/ SimpleSitemapController.php, line 54
Class
- SimpleSitemapController
- Class SimpleSitemapController
Namespace
Drupal\simple_sitemap\ControllerCode
public function getSitemap(Request $request, ?string $variant = NULL) : Response {
$output = $this->generator
->setVariants($variant)
->getSitemap($request->query
->get('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',
]);
}