You are here

private function HierarchyManager::hierarchyTreeDisableTypes in Entity Reference Hierarchy 8

Recursively mark nodes that are not of the given types as disabled.

Parameters

$nodes: The list of nodes to process and mark as disabled where applicable.

array $allowed_types: The list of allowed child types

Return value

object $nodes The updated tree of nodes with appropriate nodes marked as disabled.

See also

hierarchyParentOptions

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

Class

HierarchyManager
Defines a hierarchy manager.

Namespace

Drupal\entity_hierarchy

Code

private function hierarchyTreeDisableTypes($nodes, $allowed_types) {
  foreach ($nodes as $nid => $node) {
    if (!in_array($node->type, $allowed_types)) {
      $nodes[$nid]->disabled = TRUE;
    }
    if (!empty($node->children)) {
      $nodes[$nid]->children = $this
        ->hierarchyTreeDisableTypes($node->children, $allowed_types);
    }
  }
  return $nodes;
}