function SystemMenuBlockTest::getActiveTrailItems
Helper method to get the IDs of the menu items in the active trail.
Parameters
array $items: The #items from the return value of MenuLinkTree::build().
Return value
list<string> List of menu item IDs in the active trail.
1 call to SystemMenuBlockTest::getActiveTrailItems()
- SystemMenuBlockTest::testConfigExpanded in core/
modules/ system/ tests/ src/ Kernel/ Block/ SystemMenuBlockTest.php - Tests the config expanded option.
File
-
core/
modules/ system/ tests/ src/ Kernel/ Block/ SystemMenuBlockTest.php, line 570
Class
Namespace
Drupal\Tests\system\Kernel\BlockCode
protected function getActiveTrailItems(array $items) : array {
$active_trail_items = [];
foreach ($items as $key => $item) {
if ($item['in_active_trail']) {
$active_trail_items[] = $key;
if ($item['below']) {
$active_trail_items = array_merge($active_trail_items, $this->getActiveTrailItems($item['below']));
}
}
}
return $active_trail_items;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.