You are here

class BookNodeIsRemovableAccessCheck in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php \Drupal\book\Access\BookNodeIsRemovableAccessCheck
  2. 10 core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php \Drupal\book\Access\BookNodeIsRemovableAccessCheck

Determines whether the requested node can be removed from its book.

Hierarchy

Expanded class hierarchy of BookNodeIsRemovableAccessCheck

1 string reference to 'BookNodeIsRemovableAccessCheck'
book.services.yml in core/modules/book/book.services.yml
core/modules/book/book.services.yml
1 service uses BookNodeIsRemovableAccessCheck
access_check.book.removable in core/modules/book/book.services.yml
Drupal\book\Access\BookNodeIsRemovableAccessCheck

File

core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php, line 13

Namespace

Drupal\book\Access
View source
class BookNodeIsRemovableAccessCheck implements AccessInterface {

  /**
   * Book Manager Service.
   *
   * @var \Drupal\book\BookManagerInterface
   */
  protected $bookManager;

  /**
   * Constructs a BookNodeIsRemovableAccessCheck object.
   *
   * @param \Drupal\book\BookManagerInterface $book_manager
   *   Book Manager Service.
   */
  public function __construct(BookManagerInterface $book_manager) {
    $this->bookManager = $book_manager;
  }

  /**
   * Checks access for removing the node from its book.
   *
   * @param \Drupal\node\NodeInterface $node
   *   The node requested to be removed from its book.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(NodeInterface $node) {
    return AccessResult::allowedIf($this->bookManager
      ->checkNodeIsRemovable($node))
      ->addCacheableDependency($node);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BookNodeIsRemovableAccessCheck::$bookManager protected property Book Manager Service.
BookNodeIsRemovableAccessCheck::access public function Checks access for removing the node from its book.
BookNodeIsRemovableAccessCheck::__construct public function Constructs a BookNodeIsRemovableAccessCheck object.