protected function DevelDataCollector::develMenuLinks in Devel 4.x
Same name and namespace in other branches
- 8.3 webprofiler/src/DataCollector/DevelDataCollector.php \Drupal\webprofiler\DataCollector\DevelDataCollector::develMenuLinks()
- 8 webprofiler/src/DataCollector/DevelDataCollector.php \Drupal\webprofiler\DataCollector\DevelDataCollector::develMenuLinks()
- 8.2 webprofiler/src/DataCollector/DevelDataCollector.php \Drupal\webprofiler\DataCollector\DevelDataCollector::develMenuLinks()
Parameters
string $original_url:
Return value
array Array containing Devel Menu links Array containing Devel Menu links
1 call to DevelDataCollector::develMenuLinks()
- DevelDataCollector::getLinks in webprofiler/
src/ DataCollector/ DevelDataCollector.php
File
- webprofiler/
src/ DataCollector/ DevelDataCollector.php, line 72
Class
- DevelDataCollector
- Class DevelDataCollector.
Namespace
Drupal\webprofiler\DataCollectorCode
protected function develMenuLinks($original_url) {
// We cannot use injected services here because at this point this
// class is deserialized from a storage and not constructed.
$menuLinkTreeService = \Drupal::service('menu.link_tree');
$rendererService = \Drupal::service('renderer');
$parameters = new MenuTreeParameters();
$parameters
->setMaxDepth(1)
->onlyEnabledLinks();
$tree = $menuLinkTreeService
->load('devel', $parameters);
$manipulators = [
[
'callable' => 'menu.default_tree_manipulators:checkAccess',
],
[
'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
],
];
$tree = $menuLinkTreeService
->transform($tree, $manipulators);
$links = [];
foreach ($tree as $item) {
/** @var \Drupal\devel\Plugin\Menu\DestinationMenuLink $link */
$link = $item->link;
$renderable = Link::fromTextAndUrl($link
->getTitle(), $link
->getUrlObject())
->toRenderable();
$rendered = $rendererService
->renderPlain($renderable);
$linkString = preg_replace('/\\/profiler\\/(.*)&/', $original_url . '&', $rendered);
$links[] = Markup::create($linkString);
}
return $links;
}