Closed (fixed)
Project:
Admin Toolbar
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2026 at 00:05 UTC
Updated:
23 Nov 2026 at 20:15 UTC
Jump to comment: Most recent
As a result of the change of the minimum supported core version to 10.3 in parent issue #3565209: [Meta] Drop support for Drupal 10.2 and below, we should now be able to implement autowiring for services and controllers, as suggested in change records:
Impacted files:
autowire: true and remove arguments:use AutowireTrait and update constructors to autowire services:Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dydave commentedQuick follow-up on this issue:
All the changes detailed in the issue summary have been implemented and described in the merge request MR !203 above at #2.
Since all the tests and jobs still seem to be passing 🟢, moving issue to Needs review as an attempt to get more testing feedback and reviews.
These changes require Drupal core 10.2 or higher and should probably be merged after related:
#3569351: Drop support for Drupal 10.2 and below
Feel free to let us know if you have any comments, questions or concerns on any aspects of this issue or the suggested changes in the merge request, we would surely be glad to help.
Thanks in advance!
Comment #5
dydave commentedMerged, thanks!
The merge request switches the services and the search controller to autowiring:
admin_toolbar_tools.helperandadmin_toolbar_tools.menu_link_rebuild_managernow use_defaultswithautowireandautoconfigure, the explicitargumentswere removed. Theneeds_destructiontag of the menu link rebuild manager is kept, since core does not autoconfigure it forDestructableInterfaceanddestruct()must still run without a response (e.g. Drush).admin_toolbar_search.search_links(SearchLinks) is autowired, thecache.toolbarbin and theevent_dispatcherservice ofMenuLinkRebuildManagerare named with#[Autowire], since the class alias of the SymfonyEventDispatcherInterfaceis missing on several cores.AdminToolbarSearchControllerusesAutowireTraitand a constructor instead ofcreate().AdminToolbarToolsAutowiringTest,AdminToolbarSearchAutowiringTest), including the destructable service registration and theToolbarControllercreation without Views.images/and updated the CSS URLs accordingly, and fixed a library comment and a docblock typo.ToolbarControlleris intentionally left with itscreate()method: it depends on optional services (cache.memoryonly exists in core 11.3 and above, Views may not be installed) and before core 10.5 and 11.2AutowireTrait::create()throws an exception on missing services, even for nullable arguments. A comment was added in the code to document this, until these core versions are no longer supported.Tested with 10.3.x, 10.6.x, 11.3.x, 11.4.x and 11.5.x: all tests pass🟢.
Follow-up: the forms, the menu link plugins and
ExtraLinksstill usecreate()and could be converted in a separate issue.