You are here

public function Book::view in Sitemap 8.2

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Sitemap/Book.php \Drupal\sitemap\Plugin\Sitemap\Book::view()

Builds a renderable array for a sitemap item.

Return value

array A renderable array for a themed field with its label and all its values.

Overrides SitemapInterface::view

File

src/Plugin/Sitemap/Book.php, line 52

Class

Book
Provides a sitemap for a book.

Namespace

Drupal\sitemap\Plugin\Sitemap

Code

public function view() {

  /** @var \Drupal\book\BookManagerInterface $book_manager */
  $book_manager = \Drupal::service('book.manager');
  $book_id = $this->pluginDefinition['book'];
  $max_depth = $this->settings['show_expanded'] ? NULL : 1;
  $tree = $book_manager
    ->bookTreeAllData($book_id, NULL, $max_depth);
  $content = $book_manager
    ->bookTreeOutput($tree);
  return [
    '#theme' => 'sitemap_item',
    '#title' => $this->settings['title'],
    '#content' => $content,
    '#sitemap' => $this,
  ];
}