public function Book::view in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 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\SitemapCode
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,
];
}