You are here

class SimplesitemapController in Simple XML sitemap 8

SimplesitemapController.

Hierarchy

Expanded class hierarchy of SimplesitemapController

File

src/Controller/SimplesitemapController.php, line 16
Contains \Drupal\simplesitemap\Controller\SimplesitemapController.

Namespace

Drupal\simplesitemap\Controller
View source
class SimplesitemapController {

  /**
   * Returns the whole sitemap, a requested sitemap chunk, or the sitemap index file.
   *
   * @param int $sitemap_id
   *  Id of the sitemap chunk.
   *
   * @return object Response
   *  Returns an XML response.
   */
  public function get_sitemap($sitemap_id = NULL) {
    $sitemap = new Simplesitemap();
    $output = $sitemap
      ->get_sitemap($sitemap_id);

    // Display sitemap with correct xml header.
    $response = new CacheableResponse($output, Response::HTTP_OK, array(
      'content-type' => 'application/xml',
    ));
    $meta_data = $response
      ->getCacheableMetadata();
    $meta_data
      ->addCacheTags([
      'simplesitemap',
    ]);
    return $response;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SimplesitemapController::get_sitemap public function Returns the whole sitemap, a requested sitemap chunk, or the sitemap index file.