You are here

public function TopLevelBook::getArgument in Drupal 8

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

Return the default argument.

This needs to be overridden by every default argument handler to properly do what is needed.

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'];
    }
  }
}