You are here

private function HierarchyManager::hierarchyTreeRemoveNid in Entity Reference Hierarchy 8

Remove the option to set a child as its own parent. All decedents of the parent are also recursively removed.

Parameters

$nodes: The list of nodes to process

$exclude: Node ID of the parent that should be excluded from the list.

Return value

object The updated tree

See also

hierarchyParentOptions

1 call to HierarchyManager::hierarchyTreeRemoveNid()
HierarchyManager::hierarchyParentOptions in src/HierarchyManager.php
Return a list of valid possible hierarchy parents for the given child node type. This list is passed back to hierarchyGetParentSelector so it can be displayed as a dropdown selection list.

File

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

Class

HierarchyManager
Defines a hierarchy manager.

Namespace

Drupal\entity_hierarchy

Code

private function hierarchyTreeRemoveNid($nodes, $exclude) {
  foreach ($nodes as $nid => $node) {
    if ($nid == $exclude) {
      unset($nodes[$nid]);
    }
    else {
      if (!empty($node->children)) {
        $nodes[$nid]->children = $this
          ->hierarchyTreeRemoveNid($node->children, $exclude);
      }
    }
  }
  return $nodes;
}