BookNodeIsRemovableAccessCheck.php

Same filename in other branches
  1. 8.9.x core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php
  2. 10 core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php
  3. 11.x core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php

Namespace

Drupal\book\Access

File

core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php

View source
<?php

namespace Drupal\book\Access;

use Drupal\book\BookManagerInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\node\NodeInterface;

/**
 * Determines whether the requested node can be removed from its book.
 */
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);
    }

}

Classes

Title Deprecated Summary
BookNodeIsRemovableAccessCheck Determines whether the requested node can be removed from its book.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.