You are here

public static function TreeRebuilder::rebuildTree in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 src/Storage/TreeRebuilder.php \Drupal\entity_hierarchy\Storage\TreeRebuilder::rebuildTree()

File

src/Storage/TreeRebuilder.php, line 123

Class

TreeRebuilder
Defines a class for rebuilding the tree.

Namespace

Drupal\entity_hierarchy\Storage

Code

public static function rebuildTree($field_name, $entity_type_id, $entity_id, &$context) {

  //@codingStandardsIgnoreEnd
  $entity = \Drupal::entityTypeManager()
    ->getStorage($entity_type_id)
    ->load($entity_id);
  $entity
    ->get($field_name)
    ->postSave(TRUE);
  self::debug(sprintf('Rebuilt %s', $entity_id));
  $context['results'][] = $entity_id;
}