function xmlsitemap_output_file in XML sitemap 8
Same name and namespace in other branches
- 6.2 xmlsitemap.pages.inc \xmlsitemap_output_file()
- 7.2 xmlsitemap.pages.inc \xmlsitemap_output_file()
Creates a response reading the sitemap file and adding content to response.
Parameters
\Symfony\Component\HttpFoundation\Response $response: Response object.
string $file: File uri.
array $headers: Headers of the response.
Return value
\Symfony\Component\HttpFoundation\BinaryFileResponse The sitemap response object.
Throws
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException If the sitemap is not found or the sitemap file is not readable.
Deprecated
in xmlsitemap:8.x-1.0 and is removed from xmlsitemap:2.0.0. Use \Drupal\xmlsitemap\Controller\XmlSitemapController::getSitemapResponse() instead.
See also
https://www.drupal.org/project/xmlsitemap/issues/2869214
File
- ./
xmlsitemap.module, line 2310 - xmlsitemap XML sitemap
Code
function xmlsitemap_output_file(Response $response, $file, array $headers = []) {
@trigger_error(__FUNCTION__ . ' is deprecated in xmlsitemap:8.x-1.0 and will be removed in xmlsitemap:2.0.0. Use \\Drupal\\xmlsitemap\\Controller\\XmlSitemapController::getSitemapResponse. See https://www.drupal.org/project/xmlsitemap/issues/2869214', E_USER_DEPRECATED);
/** @var \Drupal\xmlsitemap\Controller\XmlSitemapController $controller */
$controller = \Drupal::classResolver(XmlSitemapController::class);
return $controller
->getSitemapResponse($file, \Drupal::request(), $headers + $response->headers
->all());
}