function 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 73
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 = array(
array(
'callable' => 'menu.default_tree_manipulators:checkAccess',
),
array(
'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
),
);
$tree = $menuLinkTreeService->transform($tree, $manipulators);
$links = array();
foreach ($tree as $item) {
/** @var 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;
}