Comments

DuneBL created an issue. See original summary.

eme’s picture

Content > media does not seem to come from core, does it ?

dunebl’s picture

@eme: No, "Content > media" doesn't come from core, but I was thinking that the behavior of this module was inline with the D7 version in which the menu items are auto-discovered. I am sorry if I made a mistake.

dunebl’s picture

@eme: Just to add that Taxonomy > {Voc Name} > List do come from core

eme’s picture

Title: Some menu items are mising » Integration with media entity
Issue summary: View changes
romainj’s picture

I think that what we face here is that tab links are not auto-generated as menu links with Admin Toolbar Extra Tools. That would be nice but it needs a deeper interaction between tab and menu links. Drupal has a strict separation of concern between the two.
Still that's not something that is impossible but it needs quite a lot of work. We should think at it as a future feature as this issue suggests.

dunebl’s picture

I have made a patch which is adding the local tasks to the already stored links.
There are few problem with this patch:
-2 or 3 links are duplicated
-Few links are missing
But I think it is good starting point.

joachim’s picture

Title: Integration with media entity » Local tasks don't show in the toolbar
Category: Feature request » Bug report
Priority: Normal » Major
Status: Active » Needs work

I'd say this is a bug, and a pretty major one at that.

Patch works for me, looking at the Content menu, but it needs some work with formatting, and also #7 says that there are some functional problems with it.

Eg:

+++ b/admin_toolbar_tools/admin_toolbar_tools.module
@@ -454,6 +454,83 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
+            $exists = false;
+            $param=false;

Should be FALSE in caps, and need space both side of = (here and in other places too).

kbasarab’s picture

Category: Bug report » Feature request
StatusFileSize
new3.63 KB
new5.21 KB

I wasn't able to get this to work when I installed but did cleanup a lot of the basic code style issues. One note we should try to look at here is we are 6 layers deep in if statements and indention on the patch. Wondering if we can clean this up any or execute this without looping through all existing links in the menu system.

Also setting back to feature request as even though this was in D7 version it hasn't been part of D8 which isn't a bug as it isn't existing functionality. Many modules going from D7 to D8 lost or changed functionality.

zerolab’s picture

Status: Needs work » Needs review
joachim’s picture

+++ b/admin_toolbar_tools/admin_toolbar_tools.module
@@ -468,6 +468,83 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
+  foreach ($links as $key => $link) {
+    if (isset($link['route_name'])) {

Within a foreach loop, an alternative pattern to lots of nested ifs is to line them up in sequence and bail the loop with continue:

foreach (thing) {
  if (rubbish) {
    // Skip if rubbish.
    continue;
  }
  if (not interesting) {
    // Skip if not interesting.
    continue;
  }

 // Now do something if still here.
}

I tend to prefer that, as I find it more readable.

stefan.r’s picture

StatusFileSize
new3.31 KB
new6.53 KB
new326 bytes
berdir’s picture

This is nice, seems to work well here on a pretty big site with lots of modules.

I think quite a few other hardcoded local tasks could be removed in favor of the generic solution. Especially if it would include local actions as well, which could be a separate issue. But that too could be a follow-up.

dunebl’s picture

On 8.4, patch #12apply with an offset:

patching file admin_toolbar_tools/admin_toolbar_tools.module
Hunk #1 succeeded at 509 with fuzz 1 (offset 20 lines).

... and the site is crashing after applying it:

he website encountered an unexpected error. Please try again later.
Recoverable fatal error: Argument 1 passed to Drupal\config_translation\ConfigEntityMapper::setEntity() must implement interface Drupal\Core\Config\Entity\ConfigEntityInterface, null given, called in /var/www/drupal8/core/modules/config_translation/src/ConfigEntityMapper.php on line 110 and defined in Drupal\config_translation\ConfigEntityMapper->setEntity() (line 138 of core/modules/config_translation/src/ConfigEntityMapper.php).
Drupal\config_translation\ConfigEntityMapper->setEntity(NULL) (Line: 110)
Drupal\config_translation\ConfigEntityMapper->populateFromRouteMatch(Object) (Line: 85)
Drupal\config_translation\Access\ConfigTranslationOverviewAccess->getMapperFromRouteMatch(Object) (Line: 58)
Drupal\config_translation\Access\ConfigTranslationOverviewAccess->access(Object, Object)
call_user_func_array(Array, Array) (Line: 159)
Drupal\Core\Access\AccessManager->performCheck('config_translation.access.overview', Object) (Line: 135)
Drupal\Core\Access\AccessManager->check(Object, Object, NULL, 1) (Line: 92)
Drupal\Core\Access\AccessManager->checkNamedRoute('entity.block_content_type.config_translation_overview', Array, Object, 1) (Line: 327)
Drupal\Core\Menu\LocalTaskManager->getTasksBuild('entity.block_content_type.edit_form', Object) (Line: 358)
Drupal\Core\Menu\LocalTaskManager->getLocalTasks('entity.block_content_type.edit_form', 0) (Line: 518)
admin_toolbar_tools_menu_links_discovered_alter(Array, NULL, NULL) (Line: 501)
Drupal\Core\Extension\ModuleHandler->alter('menu_links_discovered', Array) (Line: 168)
Drupal\Core\Menu\MenuLinkManager->getDefinitions() (Line: 191)
Drupal\Core\Menu\MenuLinkManager->rebuild() (Line: 61)
Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild() (Line: 49)
Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild(Object, 'routing.route_finished', Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('routing.route_finished', Object) (Line: 192)
Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 1141)
drupal_flush_all_caches() (Line: 86)
Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
joachim’s picture

The problem was that we were adding this to the array early on in the loop:

        $links[$key . '_' . $local_route]['route_parameters'] = $link['route_parameters'];

and then sometimes bailing on the iteration, and so leaving a malformed link.

Here's an updated patch, with a few other tweaks too.

dunebl’s picture

StatusFileSize
new26.49 KB

#15 is a marvellous step forward!!!
Many thanks joachim.
There are still few blank links (see my screenshot)
Those seems to be local tasks of type "Translate XXX settings" (maybe coming from the "Configuration Translation" module [config_translation])

adriancid’s picture

Status: Needs review » Needs work
StatusFileSize
new112.4 KB
new136.21 KB

Having the media module installed I have the following error:

    Notice: Undefined index: entity.file_type.collection in admin_toolbar_tools_menu_links_discovered_alter() (line 596 of modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module).

    admin_toolbar_tools_menu_links_discovered_alter(Array, NULL, NULL) (Line: 501)
    Drupal\Core\Extension\ModuleHandler->alter('menu_links_discovered', Array) (Line: 168)
    Drupal\Core\Menu\MenuLinkManager->getDefinitions() (Line: 191)
    Drupal\Core\Menu\MenuLinkManager->rebuild() (Line: 61)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild() (Line: 49)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild(Object, 'routing.route_finished', Object) (Line: 108)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('routing.route_finished', Object) (Line: 192)
    Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
    Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 1141)
    drupal_flush_all_caches() (Line: 145)
    Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    call_user_func_array(Object, Array) (Line: 153)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Notice: Undefined index: entity.file_type.collection in admin_toolbar_tools_menu_links_discovered_alter() (line 596 of modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module).

    admin_toolbar_tools_menu_links_discovered_alter(Array, NULL, NULL) (Line: 501)
    Drupal\Core\Extension\ModuleHandler->alter('menu_links_discovered', Array) (Line: 168)
    Drupal\Core\Menu\MenuLinkManager->getDefinitions() (Line: 191)
    Drupal\Core\Menu\MenuLinkManager->rebuild() (Line: 61)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild() (Line: 49)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild(Object, 'routing.route_finished', Object) (Line: 108)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('routing.route_finished', Object) (Line: 192)
    Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
    Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 1141)
    drupal_flush_all_caches() (Line: 145)
    Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    call_user_func_array(Object, Array) (Line: 153)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Notice: Undefined index: entity.file_type.collection in admin_toolbar_tools_menu_links_discovered_alter() (line 596 of modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module).

    admin_toolbar_tools_menu_links_discovered_alter(Array, NULL, NULL) (Line: 501)
    Drupal\Core\Extension\ModuleHandler->alter('menu_links_discovered', Array) (Line: 168)
    Drupal\Core\Menu\MenuLinkManager->getDefinitions() (Line: 191)
    Drupal\Core\Menu\MenuLinkManager->rebuild() (Line: 61)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild() (Line: 49)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild(Object, 'routing.route_finished', Object) (Line: 108)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('routing.route_finished', Object) (Line: 192)
    Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
    Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 1141)
    drupal_flush_all_caches() (Line: 145)
    Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    call_user_func_array(Object, Array) (Line: 153)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Notice: Undefined index: entity.file_type.collection in admin_toolbar_tools_menu_links_discovered_alter() (line 596 of modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module).

    admin_toolbar_tools_menu_links_discovered_alter(Array, NULL, NULL) (Line: 501)
    Drupal\Core\Extension\ModuleHandler->alter('menu_links_discovered', Array) (Line: 168)
    Drupal\Core\Menu\MenuLinkManager->getDefinitions() (Line: 191)
    Drupal\Core\Menu\MenuLinkManager->rebuild() (Line: 61)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild() (Line: 49)
    Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild(Object, 'routing.route_finished', Object) (Line: 108)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('routing.route_finished', Object) (Line: 192)
    Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
    Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 1141)
    drupal_flush_all_caches() (Line: 145)
    Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll()
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    call_user_func_array(Object, Array) (Line: 153)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

And see the pictures for other problems:

error

error

berdir’s picture

@adriancid: That error sounds like it is related to the file_entity module, are you using both file_entity and media? that doesn't sound like a good idea. I think that should be investigated, but I actually can't reproduce that file_entity enabled and I also don't see those menu links added in the wrong place anymore.

A client reported that this was adding additonal menu links to e.g. edit terms into non-admin menus, I think they don't belong there, so I added a check to ignore all non-admin menu links, I don't think that admin_toolbar should mess with those other menus. If someone thinks there is a use case for that, it could be made configurable, but that's IMHO quite likely to mess up public menus and a bad idea.

It should also be possible to add a similar check to prevent creating empty menu links.

  • adriancid committed 1205961 on 8.x-1.x authored by DuneBL
    Issue #2731369 by stefan.r, DuneBL, Berdir, kbasarab, joachim, adriancid...
adriancid’s picture

adriancid’s picture

Status: Needs review » Fixed
adriancid’s picture

Thanks to @all, this is a great improvement to the module!

Thanks @Berdir for the fix, and yes I have the two modules you mentioned because is a test site with a lots of module inside, and usually I install and keep the module in the site, when the site crash, I install a fresh one to start again adding modules to test :-)

mikejw’s picture

I get a similar error to @adriancid with the workflow module installed. Changing line 599 to: if (!empty($link['parent']) && isset($links[$link['parent']])) { fixes it for me... I will create another issue around this.

adriancid’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.