You are here

private function HierarchyManager::hierarchyTreeDisableNoAccess in Entity Reference Hierarchy 8

Recursively mark as disabled nodes for which the user doesn't have edit access.

Parameters

$nodes: The list of nodes to process for access permissions

Return value

object The updated list of nodes with no access nodes marked as disabled.

See also

hierarchyParentOptions

File

src/HierarchyManager.php, line 532
Contains \Drupal\entity_hierarchy\HierarchyManager.

Class

HierarchyManager
Defines a hierarchy manager.

Namespace

Drupal\entity_hierarchy

Code

private function hierarchyTreeDisableNoAccess(NodeInterface $nodes) {

  // Todo: fix this function
  $current_user = \Drupal::currentUser();
  if (!$current_user
    ->hasPermission('create child of any parent')) {
    foreach ($nodes as $nid => $node) {
      $nodes[$nid]->disabled = $nodes[$nid]->disabled || !$node
        ->access('update');
      if (!empty($node->children)) {
        $nodes[$nid]->children = $this
          ->hierarchyTreeDisableNoAccess($node->children);
      }
    }
  }
  return $nodes;
}