You are here

private function HierarchyManager::hierarchyBuildTree in Entity Reference Hierarchy 8

Build a tree of all possible parent nodes. This method is only called for a given node type.

Parameters

$nodes: The list of nodes to process

Return value

object The updated tree of nodes

See also

hierarchyParentOptions

1 call to HierarchyManager::hierarchyBuildTree()
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 478
Contains \Drupal\entity_hierarchy\HierarchyManager.

Class

HierarchyManager
Defines a hierarchy manager.

Namespace

Drupal\entity_hierarchy

Code

private function hierarchyBuildTree($nodes) {
  foreach ($nodes as $node) {
    $node->is_child = FALSE;
    $node->disabled = FALSE;
    if (!empty($node->pnid)) {
      if (isset($nodes[$node->pnid])) {
        $node->is_child = TRUE;
        $nodes[$node->pnid]->children[$node->nid] =& $nodes[$node->nid];
      }
    }
  }
  foreach ($nodes as $nid => $node) {
    if ($node->is_child) {
      unset($nodes[$nid]);
    }
  }
  return $nodes;
}