SimplesitemapController.php 964 Bytes
Newer Older
gbyte.co's avatar
gbyte.co committed
1 2 3
<?php
/**
 * @file
gbyte.co's avatar
gbyte.co committed
4
 * Contains \Drupal\simple_sitemap\Controller\SimplesitemapController.
gbyte.co's avatar
gbyte.co committed
5 6
 */

gbyte.co's avatar
gbyte.co committed
7
namespace Drupal\simple_sitemap\Controller;
gbyte.co's avatar
gbyte.co committed
8

9
//use Drupal\Core\Cache\CacheableResponse;
gbyte.co's avatar
gbyte.co committed
10
use Symfony\Component\HttpFoundation\Response;
gbyte.co's avatar
gbyte.co committed
11
use Drupal\simple_sitemap\Simplesitemap;
gbyte.co's avatar
gbyte.co committed
12 13 14 15 16 17 18

/**
 * SimplesitemapController.
 */
class SimplesitemapController {

  /**
19
   * Returns the whole sitemap, a requested sitemap chunk, or the sitemap index file.
20 21 22 23 24 25
   *
   * @param int $sitemap_id
   *  Id of the sitemap chunk.
   *
   * @return object Response
   *  Returns an XML response.
gbyte.co's avatar
gbyte.co committed
26
   */
27
  public function get_sitemap($sitemap_id = NULL) {
28
    $sitemap = new Simplesitemap;
29
    $output = $sitemap->get_sitemap($sitemap_id);
gbyte.co's avatar
gbyte.co committed
30

31
    // Display sitemap with correct xml header.
32 33
//    return new CacheableResponse($output, Response::HTTP_OK, array('content-type' => 'application/xml'));
    return new Response($output, Response::HTTP_OK, array('content-type' => 'application/xml'));
gbyte.co's avatar
gbyte.co committed
34 35
  }
}