public function Toolbar::treeOptions in Simplifying 8
Get menu tree options.
1 call to Toolbar::treeOptions()
- Toolbar::formFields in src/
Services/ Toolbar.php - Get settings toolbar form fields.
File
- src/
Services/ Toolbar.php, line 159
Class
- Toolbar
- Class Toolbar.
Namespace
Drupal\simplifying\ServicesCode
public function treeOptions($tree, &$options, $tree_rout) {
if (isset($tree['system.admin'])) {
$tree = [
'system.admin' => $tree['system.admin'],
];
}
foreach ($tree as $rout => $val) {
$new_tree_rout = $tree_rout . ' | ' . $rout;
if (!empty($val->link)) {
$link = $val->link;
if ($link
->getRouteName()) {
$path = Url::fromRoute($link
->getRouteName(), $link
->getRouteParameters(), $link
->getOptions())
->getInternalPath();
if (!empty($path)) {
$title = $link
->getTitle();
$options[$new_tree_rout] = [
'title' => $title,
'depth' => $val->depth,
'path' => $path,
'rout' => $rout,
];
}
}
}
if (!empty($val->subtree)) {
$this
->treeOptions($val->subtree, $options, $new_tree_rout);
}
}
}