generalize creation of 'add ENTITY' and 'add BUNDLE' links

Created on 24 January 2019, almost 6 years ago
Updated 28 February 2023, almost 2 years ago

The code in admin_toolbar_tools_menu_links_discovered_alter() adds links to the Content menu for adding a new entity, with a submenu of links for the different bundles, but this is hardcoded for node and media modules.

It would be better to do this generically, so all modules that have standard route names from DefaultHtmlRouteProvider get these links automatically.

Patch coming.

Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States erutan

    Applying this patch on both 3.3.0 and dev of admin_toolbar gives me the following error after clearing caches. Drupal 9.5.3 and Feeds Beta 3. If I'm understanding this correctly, it seems like this patch should skip over a bad, missing, or misconfigured route vs fatally trying to create it.

    Rolling back the patch and rebuilding the cache fixed the issue. :)

    The website encountered an unexpected error. Please try again later.
    
    Symfony\Component\Routing\Exception\RouteNotFoundException: Route "entity.feeds_feed.collection" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 206 of core/lib/Drupal/Core/Routing/RouteProvider.php).
    Drupal\Core\Routing\UrlGenerator->getRoute() (Line: 129)
    Drupal\Core\Routing\UrlGenerator->getPathFromRoute() (Line: 68)
    Drupal\Core\Render\MetadataBubblingUrlGenerator->getPathFromRoute() (Line: 802)
    Drupal\Core\Url->getInternalPath() (Line: 136)
    Drupal\Core\Utility\LinkGenerator->generate() (Line: 95)
    Drupal\Core\Render\Element\Link::preRenderLink()
    call_user_func_array() (Line: 101)
    Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 788)
    Drupal\Core\Render\Renderer->doCallback() (Line: 374)
    Drupal\Core\Render\Renderer->doRender() (Line: 204)
    Drupal\Core\Render\Renderer->render() (Line: 479)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 102)
    __TwigTemplate_12e0ac103d6d37453e250b27d8442420->macro_menu_links() (Line: 1169)
    twig_call_macro() (Line: 44)
    __TwigTemplate_12e0ac103d6d37453e250b27d8442420->doDisplay() (Line: 405)
    Twig\Template->displayWithErrorHandling() (Line: 378)
    Twig\Template->display() (Line: 390)
    Twig\Template->render() (Line: 55)
    twig_render_template() (Line: 384)
    Drupal\Core\Theme\ThemeManager->render() (Line: 433)
    Drupal\Core\Render\Renderer->doRender() (Line: 204)
    Drupal\Core\Render\Renderer->render() (Line: 118)
    Drupal\toolbar\Controller\ToolbarController::Drupal\toolbar\Controller\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 119)
    Drupal\toolbar\Controller\ToolbarController::preRenderGetRenderedSubtrees()
    call_user_func_array() (Line: 101)
    Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 788)
    Drupal\Core\Render\Renderer->doCallback() (Line: 374)
    Drupal\Core\Render\Renderer->doRender() (Line: 204)
    Drupal\Core\Render\Renderer->render() (Line: 285)
    {closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 286)
    toolbar_get_rendered_subtrees() (Line: 297)
    _toolbar_get_subtrees_hash() (Line: 168)
    toolbar_toolbar()
    call_user_func_array() (Line: 426)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 405)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 433)
    Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 81)
    Drupal\toolbar\Element\Toolbar::preRenderToolbar()
    call_user_func_array() (Line: 101)
    Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 788)
    Drupal\Core\Render\Renderer->doCallback() (Line: 374)
    Drupal\Core\Render\Renderer->doRender() (Line: 446)
    Drupal\Core\Render\Renderer->doRender() (Line: 204)
    Drupal\Core\Render\Renderer->render() (Line: 479)
    Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 82)
    __TwigTemplate_84b190a55469c4f95ce742f2e57ac716->doDisplay() (Line: 405)
    Twig\Template->displayWithErrorHandling() (Line: 378)
    Twig\Template->display() (Line: 390)
    Twig\Template->render() (Line: 55)
    twig_render_template() (Line: 384)
    Drupal\Core\Theme\ThemeManager->render() (Line: 433)
    Drupal\Core\Render\Renderer->doRender() (Line: 204)
    Drupal\Core\Render\Renderer->render() (Line: 162)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 163)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 142)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 174)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
    Stack\StackedHttpKernel->handle() (Line: 713)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
  • 🇬🇧United Kingdom joachim

    Cleaning up the issue fork before rebasing the feature branch.

    There's a bit of a mess here -- the feature branch, `3028213-generalize-creation-of` had no content on it, was on the main 3.x trunk, and the issue fork's 3.x had feature commits that correspond to patch #23!

  • 🇬🇧United Kingdom joachim

    joachim changed the visibility of the branch 3.x to hidden.

  • 🇬🇧United Kingdom joachim

    MR 34 needs to be closed -- it's for the wrong branches.

  • Pipeline finished with Failed
    3 months ago
    Total: 389s
    #299886
Production build 0.71.5 2024