class BookSitemapDeriver in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 src/Plugin/Derivative/BookSitemapDeriver.php \Drupal\sitemap\Plugin\Derivative\BookSitemapDeriver
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\sitemap\Plugin\Derivative\BookSitemapDeriver implements ContainerDeriverInterface
Expanded class hierarchy of BookSitemapDeriver
File
- src/
Plugin/ Derivative/ BookSitemapDeriver.php, line 13
Namespace
Drupal\sitemap\Plugin\DerivativeView source
class BookSitemapDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* The book manager.
*
* @var \Drupal\book\BookManagerInterface
*/
protected $bookManager;
/**
* Constructs new SitemapBooks sitemap_map.
*
* @param \Drupal\book\BookManagerInterface $book_manager
* The book manager.
*/
public function __construct(BookManagerInterface $book_manager) {
$this->bookManager = $book_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
if (\Drupal::moduleHandler()
->moduleExists('book')) {
return new static($container
->get('book.manager'));
}
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
if (\Drupal::moduleHandler()
->moduleExists('book')) {
foreach ($this->bookManager
->getAllBooks() as $id => $book) {
$this->derivatives[$id] = $base_plugin_definition;
$this->derivatives[$id]['title'] = t('Book: @book', [
'@book' => $book['title'],
]);
$this->derivatives[$id]['description'] = $book['type'];
$this->derivatives[$id]['settings']['title'] = '';
$this->derivatives[$id]['book'] = $id;
$this->derivatives[$id]['config_dependencies']['config'] = [
'book.settings',
];
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BookSitemapDeriver:: |
protected | property | The book manager. | |
BookSitemapDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
BookSitemapDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
BookSitemapDeriver:: |
public | function | Constructs new SitemapBooks sitemap_map. | |
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |