You are here

protected function SystemMenuBlockTest::convertBuiltMenuToIdTree in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Block/SystemMenuBlockTest.php \Drupal\system\Tests\Block\SystemMenuBlockTest::convertBuiltMenuToIdTree()

Helper method to allow for easy menu link tree structure assertions.

Converts the result of MenuLinkTree::build() in a "menu link ID tree".

Parameters

array $build: The return value of MenuLinkTree::build()

Return value

array The "menu link ID tree" representation of the given render array.

1 call to SystemMenuBlockTest::convertBuiltMenuToIdTree()
SystemMenuBlockTest::testConfigLevelDepth in core/modules/system/src/Tests/Block/SystemMenuBlockTest.php
Tests the config start level and depth.

File

core/modules/system/src/Tests/Block/SystemMenuBlockTest.php, line 303
Contains \Drupal\system\Tests\Block\SystemMenuBlockTest.

Class

SystemMenuBlockTest
Tests \Drupal\system\Plugin\Block\SystemMenuBlock.

Namespace

Drupal\system\Tests\Block

Code

protected function convertBuiltMenuToIdTree(array $build) {
  $level = [];
  foreach (Element::children($build) as $id) {
    $level[$id] = [];
    if (isset($build[$id]['below'])) {
      $level[$id] = $this
        ->convertBuiltMenuToIdTree($build[$id]['below']);
    }
  }
  return $level;
}