It would be nice and very helpful to add the devel menu's links to the toolbar. The result would be something like the attached image


webprofiler-devel-menu.jpg

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

willzyx’s picture

Status: Active » Needs review
FileSize
6.59 KB
lussoluca’s picture

This is a good idea,
I just wonder if this datacollector should be into Devel and not into Webprofiler. At the same time I think we have to remove overlapping functionalities from Devel (query log and memory/time log).

lussoluca’s picture

Project: WebProfiler » Devel
Component: Code » devel

Moved to the Devel issue queue

moshe weitzman’s picture

I'm open to moving things around between webprofiler and devel. webprofiler is awesome!

lussoluca’s picture

Hi Moshe,
maybe we could open a meta issue when we can discuss what we want to move around?

moshe weitzman’s picture

Title: Add Devel Menu's links to the toolbar » Add Devel Menu's links as a webprofiler datacollector
lussoluca’s picture

Component: devel » webprofiler
FileSize
7.77 KB

Now that Webprofiler is in Devel add a datacollector for the Devel's menu make much more sense.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

willzyx’s picture

+++ b/webprofiler/src/DataCollector/DevelDataCollector.php
@@ -0,0 +1,108 @@
+    $manipulators = array(
+      array('callable' => 'menu.default_tree_manipulators:checkAccess'),
+      array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
+    );
+    $tree = $this->menuLinkTree->transform($tree, $manipulators);
+
+    $links = array();
+
+    foreach ($tree as $item) {
+      $links[] = array(
+        'title' => $item->link->getTitle(),
+        'description' => $item->link->getDescription(),
+        'url' => $item->link->getUrlObject()->toString(),
+      );
+    }

Top-level inaccessible links are *not* removed automatically (see DefaultMenuLinkTreeManipulators::checkAccess()); we should iterate over the links and exclude inaccessible links. Something like

foreach ($tree as $item) {
  if ($item->access->isAllowed()) {
   $links[] = array(
     'title' => $item->link->getTitle(),
     'description' => $item->link->getDescription(),
     'url' => $item->link->getUrlObject()->toString(),
    );
  }
}

otherwise looks good :)

  • lussoluca committed 449d8ed on 8.x-1.x
    Issue #2410459 by willzyx, lussoluca: Add Devel Menu's links as a...
lussoluca’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Committed to 8.x-1.x (with fix from #9). Thanks!