You are here

public function TopLevelBook::getArgument in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php \Drupal\book\Plugin\views\argument_default\TopLevelBook::getArgument()
  2. 9 core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php \Drupal\book\Plugin\views\argument_default\TopLevelBook::getArgument()

Overrides Node::getArgument

File

core/modules/book/src/Plugin/views/argument_default/TopLevelBook.php, line 62

Class

TopLevelBook
Default argument plugin to get the current node's top level book.

Namespace

Drupal\book\Plugin\views\argument_default

Code

public function getArgument() {

  // Use the argument_default_node plugin to get the nid argument.
  $nid = parent::getArgument();
  if (!empty($nid)) {
    $node = $this->nodeStorage
      ->load($nid);
    if (isset($node->book['bid'])) {
      return $node->book['bid'];
    }
  }
}