public function RenderCheeseburgerMenuBlock::findChildren in Cheeseburger Menu 8.3
Same name and namespace in other branches
- 8 src/Controller/renderCheeseburgerMenuBlock.php \Drupal\cheeseburger_menu\Controller\renderCheeseburgerMenuBlock::findChildren()
- 8.2 src/Controller/RenderCheeseburgerMenuBlock.php \Drupal\cheeseburger_menu\Controller\RenderCheeseburgerMenuBlock::findChildren()
Find all children of specific menu link.
1 call to RenderCheeseburgerMenuBlock::findChildren()
- RenderCheeseburgerMenuBlock::getMenuTree in src/
Controller/ RenderCheeseburgerMenuBlock.php - Returning menu tree data.
File
- src/
Controller/ RenderCheeseburgerMenuBlock.php, line 587 - Controller used for rendering block.
Class
- RenderCheeseburgerMenuBlock
- Class RenderCheeseburgerMenuBlock.
Namespace
Drupal\cheeseburger_menu\ControllerCode
public function findChildren($menu) {
$menu_tree_formatted = [];
if (is_array($menu) || is_object($menu)) {
foreach ($menu as $menu_data) {
if ($menu_data['url']
->isRouted()) {
$help_array = [];
$help_array['subitem'] = $this
->findChildren($menu_data['below']);
$help_array['name'] = $menu_data['title'];
try {
$help_array['id'] = $menu_data['url']
->getRouteParameters();
} catch (\Exception $exception) {
$help_array['id'][0] = NULL;
}
if (reset($help_array['id']) != NULL) {
$help_array['type'] = key($help_array['id']);
$help_array['id'] = reset($help_array['id']);
}
else {
try {
$help_array['id'] = $menu_data['url']
->getRouteName();
} catch (\Exception $exception) {
$help_array['id'] = NULL;
}
if ($help_array['id'] == "user.page") {
$user = $this
->currentUser();
$help_array['id'] = $user != NULL ? $user
->id() : $user;
$help_array['type'] = 'user';
}
else {
$help_array['type'] = 'view_id';
}
}
try {
$route_name = $menu_data['url']
->getRouteName();
} catch (\Exception $exception) {
$route_name = NULL;
}
if ($route_name != NULL) {
$url = Url::fromRoute($menu_data['url']
->getRouteName(), $menu_data['url']
->getRouteParameters());
$help_array['url'] = $url
->toString();
}
else {
$help_array['url'] = '';
}
$menu_tree_formatted[] = $help_array;
}
}
}
return $menu_tree_formatted;
}