I am attempting to add a local task here (/admin/commerce/orders/{order#}). This local task should contain a view that takes the userid from the current order and displays that users order history.
I believe I have the view set up correctly and I can successfully add a local task here (admin/people/%user/orders) by adding the following to my links.tasks.yml:
custom_module.people.user_orders: route_name: view.orders.page_2 base_route: entity.user.canonical title: 'Orders' parent: entity.user.canonical weight: 100
If I go to /admin/people/1/orders while this task is uncommented, I do indeed get a list of this user’s orders and the tab itself lives under the Home>Administration>People part of the site.
However, if I remove this local task and replace it with the following, I get an error:
custom_module.commerce_order.user_orders: route_name: view.orders.page_2 base_route: entity.commerce_order.canonical title: 'Orders' parent: entity.commerce_order.canonical weight: 16 class: 'Drupalcustom_modulePluginMenuUserOrdersDynamicTab'
UserOrdersDynamicTab.php:
namespace Drupalcustom_modulePluginMenu; use DrupalCoreMenuLocalTaskDefault; use DrupalCoreRoutingRouteMatchInterface; class UserOrdersDynamicTab extends LocalTaskDefault { /** * {@inheritdoc} */ public function getRouteParameters(RouteMatchInterface $route_match) { return [ 'user' => Drupal::routeMatch()->getParameter('commerce_order')->getCustomerId(), ]; } }
Uncommenting this version and commenting out the previous local task results in an error when I visit /admin/people/1/orders. To be clear, I am trying to create a local task that passes a parameter to a view. Below is the error I am getting. Thank you in advance for any help you can offer! (This is my first time posting a question here so I’m also interested in corrections to my post.)
The website encountered an unexpected error. Please try again later. Error: Call to a member function bundle() on null in Drupalcommerce_shippingAccessShipmentCollectionAccessCheck->access() (line 52 of modules/contrib/commerce_shipping/src/Access/ShipmentCollectionAccessCheck.php). Drupalcommerce_shippingAccessShipmentCollectionAccessCheck->access() call_user_func_array() (Line: 160) DrupalCoreAccessAccessManager->performCheck() (Line: 136) DrupalCoreAccessAccessManager->check() (Line: 93) DrupalCoreAccessAccessManager->checkNamedRoute() (Line: 327) DrupalCoreMenuLocalTaskManager->getTasksBuild() (Line: 358) DrupalCoreMenuLocalTaskManager->getLocalTasks() (Line: 95) DrupalCoreMenuPluginBlockLocalTasksBlock->build() (Line: 171) DrupalblockBlockViewBuilder::preRender() call_user_func_array() (Line: 101) DrupalCoreRenderRenderer->doTrustedCallback() (Line: 772) DrupalCoreRenderRenderer->doCallback() (Line: 363) DrupalCoreRenderRenderer->doRender() (Line: 435) DrupalCoreRenderRenderer->doRender() (Line: 201) DrupalCoreRenderRenderer->render() (Line: 463) DrupalCoreTemplateTwigExtension->escapeFilter() (Line: 47) __TwigTemplate_82330771d2235f13341d75dc3dba6b0551e4091dc4e3e3af75b58a51080d8b70->doDisplay() (Line: 405) TwigTemplate->displayWithErrorHandling() (Line: 378) TwigTemplate->display() (Line: 390) TwigTemplate->render() (Line: 55) twig_render_template() (Line: 384) DrupalCoreThemeThemeManager->render() (Line: 422) DrupalCoreRenderRenderer->doRender() (Line: 201) DrupalCoreRenderRenderer->render() (Line: 463) DrupalCoreTemplateTwigExtension->escapeFilter() (Line: 86) __TwigTemplate_8396bbb6a446449db2b4f79819d5586f73fc0a7bf41d2501e27ba28c058bb7b1->doDisplay() (Line: 405) TwigTemplate->displayWithErrorHandling() (Line: 378) TwigTemplate->display() (Line: 390) TwigTemplate->render() (Line: 55) twig_render_template() (Line: 384) DrupalCoreThemeThemeManager->render() (Line: 422) DrupalCoreRenderRenderer->doRender() (Line: 201) DrupalCoreRenderRenderer->render() (Line: 162) DrupalCoreRenderMainContentHtmlRenderer->DrupalCoreRenderMainContent{closure}() (Line: 564) DrupalCoreRenderRenderer->executeInRenderContext() (Line: 163) DrupalCoreRenderMainContentHtmlRenderer->renderResponse() (Line: 90) DrupalCoreEventSubscriberMainContentViewSubscriber->onViewRenderArray() call_user_func() (Line: 142) DrupalComponentEventDispatcherContainerAwareEventDispatcher->dispatch() (Line: 163) SymfonyComponentHttpKernelHttpKernel->handleRaw() (Line: 80) SymfonyComponentHttpKernelHttpKernel->handle() (Line: 58) DrupalCoreStackMiddlewareSession->handle() (Line: 48) DrupalCoreStackMiddlewareKernelPreHandle->handle() (Line: 106) Drupalpage_cacheStackMiddlewarePageCache->pass() (Line: 85) Drupalpage_cacheStackMiddlewarePageCache->handle() (Line: 48) DrupalCoreStackMiddlewareReverseProxyMiddleware->handle() (Line: 51) DrupalCoreStackMiddlewareNegotiationMiddleware->handle() (Line: 23) StackStackedHttpKernel->handle() (Line: 708) DrupalCoreDrupalKernel->handle() (Line: 19)