You are here

protected function Menu::sortTree in Workbench Access 8

Sorts the menu tree by weight.

File

src/Plugin/AccessControlHierarchy/Menu.php, line 130

Class

Menu
Defines a hierarchy based on a Menu.

Namespace

Drupal\workbench_access\Plugin\AccessControlHierarchy

Code

protected function sortTree($a, $b) {
  if ($a->link
    ->getWeight() == $b->link
    ->getWeight()) {
    return $a->link
      ->getTitle() > $b->link
      ->getTitle() ? 1 : 0;
  }
  return $a->link
    ->getWeight() > $b->link
    ->getWeight() ? 1 : 0;
}