You are here

public static function RevisionTreeIndex::sortTree in Multiversion 8

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

Parameters

array $tree:

Return value

mixed

Overrides RevisionTreeIndexInterface::sortTree

3 calls to RevisionTreeIndex::sortTree()
RevisionTreeIndex::doBuildTree in src/Entity/Index/RevisionTreeIndex.php
Recursive helper method to build the revision tree.
RevisionTreeIndexTest::testWithDelete in tests/src/Functional/RevisionTreeIndexTest.php
RevisionTreeIndexTest::testWithoutDelete in tests/src/Functional/RevisionTreeIndexTest.php

File

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

Class

RevisionTreeIndex
The revision tree index.

Namespace

Drupal\multiversion\Entity\Index

Code

public static function sortTree(array &$tree) {

  // Sort all tree elements according to the algorithm before recursing.
  usort($tree, [
    __CLASS__,
    'sortRevisions',
  ]);
  foreach ($tree as &$element) {
    if (!empty($element['children'])) {
      self::sortTree($element['children']);
    }
  }
}