SimplesitemapController.php 595 Bytes
Newer Older
Pawel G's avatar
Pawel G committed
1 2 3 4 5 6 7 8 9
<?php
/**
 * @file
 * Contains \Drupal\simplesitemap\Controller\SimplesitemapController.
 */

namespace Drupal\simplesitemap\Controller;

use Symfony\Component\HttpFoundation\Response;
10
use Drupal\simplesitemap\Simplesitemap;
Pawel G's avatar
Pawel G committed
11 12 13 14 15 16 17

/**
 * SimplesitemapController.
 */
class SimplesitemapController {

  /**
18
   * Generates the sitemap.
Pawel G's avatar
Pawel G committed
19
   */
20
  public function get_sitemap() {
Pawel G's avatar
Pawel G committed
21

22 23
    $sitemap = new Simplesitemap;
    $output = $sitemap->get_sitemap();
Pawel G's avatar
Pawel G committed
24

25
    // Display sitemap with correct xml header.
Pawel G's avatar
Pawel G committed
26 27 28
    return new Response($output, Response::HTTP_OK, array('content-type' => 'application/xml'));
  }
}