function SystemMenuBlockTest::convertBuiltMenuToIdTree

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php \Drupal\Tests\system\Kernel\Block\SystemMenuBlockTest::convertBuiltMenuToIdTree()
  2. 10 core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php \Drupal\Tests\system\Kernel\Block\SystemMenuBlockTest::convertBuiltMenuToIdTree()
  3. 11.x core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php \Drupal\Tests\system\Kernel\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.

2 calls to SystemMenuBlockTest::convertBuiltMenuToIdTree()
SystemMenuBlockTest::testConfigExpanded in core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
Tests the config expanded option.
SystemMenuBlockTest::testConfigLevelDepth in core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
Tests the config start level and depth.

File

core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php, line 382

Class

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

Namespace

Drupal\Tests\system\Kernel\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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.