You are here

protected function RevisionTreeIndex::generateEdges in Multiversion 8.2

Same name and namespace in other branches
  1. 8 src/Entity/Index/RevisionTreeIndex.php \Drupal\multiversion\Entity\Index\RevisionTreeIndex::generateEdges()

Helper function to create Edges between parent and children.

Parameters

array $revisions_array: Associative array containing graph nodes.

array $tree: Associative array containing tree structure.

int $parent: Parent vertex Id.

1 call to RevisionTreeIndex::generateEdges()
RevisionTreeIndex::getGraph in src/Entity/Index/RevisionTreeIndex.php

File

src/Entity/Index/RevisionTreeIndex.php, line 120

Class

RevisionTreeIndex
The revision tree index.

Namespace

Drupal\multiversion\Entity\Index

Code

protected function generateEdges(array $revisions_array, array $tree, $parent = -1) {
  foreach ($tree as $item) {
    $current_id = $item['#rev'];
    if ($parent != -1) {
      $revisions_array[$parent]
        ->createEdgeTo($revisions_array[$current_id]);
    }
    if (count($item['children'])) {
      $this
        ->generateEdges($revisions_array, $item['children'], $current_id);
    }
  }
}