DefaultMenuLinkTreeManipulators::flatten

public DefaultMenuLinkTreeManipulators::flatten(array $tree)

Flattens the tree to a single level.

Parameters

\Drupal\Core\Menu\MenuLinkTreeElement[] $tree: The menu link tree to manipulate.

Return value

\Drupal\Core\Menu\MenuLinkTreeElement[] The manipulated menu link tree.

File

core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php, line 252

Class

DefaultMenuLinkTreeManipulators
Provides a couple of menu link tree manipulators.

Namespace

Drupal\Core\Menu

Code

public function flatten(array $tree) {
  foreach ($tree as $key => $element) {
    if ($tree[$key]->subtree) {
      $tree += $this->flatten($tree[$key]->subtree);
    }
    $tree[$key]->subtree = array();
  }
  return $tree;
}
doc_Drupal
2016-10-29 09:01:48
Comments
Leave a Comment

Please login to continue.