You are here

class HierarchyNodeIsRemovableAccessCheck in Entity Reference Hierarchy 8

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

Hierarchy

Expanded class hierarchy of HierarchyNodeIsRemovableAccessCheck

1 string reference to 'HierarchyNodeIsRemovableAccessCheck'
entity_hierarchy.services.yml in ./entity_hierarchy.services.yml
entity_hierarchy.services.yml
1 service uses HierarchyNodeIsRemovableAccessCheck
access_check.entity_hierarchy.removable in ./entity_hierarchy.services.yml
Drupal\entity_hierarchy\Access\HierarchyNodeIsRemovableAccessCheck

File

src/Access/HierarchyNodeIsRemovableAccessCheck.php, line 18
Contains Drupal\entity_hierarchy\Access\HierarchyNodeIsRemovableAccessCheck.

Namespace

Drupal\entity_hierarchy\Access
View source
class HierarchyNodeIsRemovableAccessCheck implements AccessInterface {

  /**
   * Hierarchy Manager Service.
   *
   * @var \Drupal\entity_hierarchy\HierarchyManagerInterface
   */
  protected $entity_hierarchyManager;

  /**
   * Constructs a HierarchyNodeIsRemovableAccessCheck object.
   *
   * @param \Drupal\entity_hierarchy\HierarchyManagerInterface $entity_hierarchy_manager
   *   Hierarchy Manager Service.
   */
  public function __construct(HierarchyManagerInterface $entity_hierarchy_manager) {
    $this->entity_hierarchyManager = $entity_hierarchy_manager;
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
HierarchyNodeIsRemovableAccessCheck::$entity_hierarchyManager protected property Hierarchy Manager Service.
HierarchyNodeIsRemovableAccessCheck::access public function Checks access for removing the node from its entity_hierarchy.
HierarchyNodeIsRemovableAccessCheck::__construct public function Constructs a HierarchyNodeIsRemovableAccessCheck object.