Mercurial > hg > isophonics-drupal-site
annotate core/modules/book/src/Access/BookNodeIsRemovableAccessCheck.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\book\Access; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\book\BookManagerInterface; |
Chris@0 | 6 use Drupal\Core\Access\AccessResult; |
Chris@0 | 7 use Drupal\Core\Routing\Access\AccessInterface; |
Chris@0 | 8 use Drupal\node\NodeInterface; |
Chris@0 | 9 |
Chris@0 | 10 /** |
Chris@0 | 11 * Determines whether the requested node can be removed from its book. |
Chris@0 | 12 */ |
Chris@0 | 13 class BookNodeIsRemovableAccessCheck implements AccessInterface { |
Chris@0 | 14 |
Chris@0 | 15 /** |
Chris@0 | 16 * Book Manager Service. |
Chris@0 | 17 * |
Chris@0 | 18 * @var \Drupal\book\BookManagerInterface |
Chris@0 | 19 */ |
Chris@0 | 20 protected $bookManager; |
Chris@0 | 21 |
Chris@0 | 22 /** |
Chris@0 | 23 * Constructs a BookNodeIsRemovableAccessCheck object. |
Chris@0 | 24 * |
Chris@0 | 25 * @param \Drupal\book\BookManagerInterface $book_manager |
Chris@0 | 26 * Book Manager Service. |
Chris@0 | 27 */ |
Chris@0 | 28 public function __construct(BookManagerInterface $book_manager) { |
Chris@0 | 29 $this->bookManager = $book_manager; |
Chris@0 | 30 } |
Chris@0 | 31 |
Chris@0 | 32 /** |
Chris@0 | 33 * Checks access for removing the node from its book. |
Chris@0 | 34 * |
Chris@0 | 35 * @param \Drupal\node\NodeInterface $node |
Chris@0 | 36 * The node requested to be removed from its book. |
Chris@0 | 37 * |
Chris@0 | 38 * @return \Drupal\Core\Access\AccessResultInterface |
Chris@0 | 39 * The access result. |
Chris@0 | 40 */ |
Chris@0 | 41 public function access(NodeInterface $node) { |
Chris@0 | 42 return AccessResult::allowedIf($this->bookManager->checkNodeIsRemovable($node))->addCacheableDependency($node); |
Chris@0 | 43 } |
Chris@0 | 44 |
Chris@0 | 45 } |