Problem/Motivation
Module won't enable.
Steps to reproduce
When enabling the module, I at met with this error in console:
[02-Jun-2022 15:08:44 UTC] PHP Fatal error: Uncaught TypeError: Drupal\menu_position\Menu\MenuPositionActiveTrail::__construct(): Argument #5 ($entity_type_manager) must be of type Drupal\Core\Entity\EntityTypeManagerInterface, Drupal\context\ContextManager given, called in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 and defined in /var/www/html/docroot/modules/contrib/menu_position/src/Menu/MenuPositionActiveTrail.php:48
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff.txt | 980 bytes | joelpittet |
#18 | 3283837-18-service-decorator.patch | 7.36 KB | joelpittet |
Issue fork menu_position-3283837
Show commands
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 #2
apadernoComment #3
apadernoBasing on
MenuPositionServiceProvider
andMenuActiveTrail::__construct()
, the fifth argument should be the entity_type.manager service.Comment #4
kevinquillen CreditAttribution: kevinquillen at Velir commentedYes, I am not sure where or how this is being overridden. Forgot to mention I am using Drupal 9.3.14.
Comment #5
joelpittetSorry for the delay but sounds like the context module is passing things in that aren't the right thing.
https://www.drupal.org/project/context
Comment #7
kevinquillen CreditAttribution: kevinquillen at Velir commentedVery possible, this issue sounds like it could be related. #3343912: Context module: "Menu Reactions" will not work because menu.active_trail has a different menu service provider.
Comment #8
joelpittet@Ranjit1032002 I see you made a commit, but I don't see it, what is your plan?
Comment #9
joelpittetSounds like context module and menu_position are both trying to replace/extend the same service 'menu.active_trail' with different args.
@kevinquillen, you're totally right in #7.
Altering the service provider sounds like a bad idea all the way around, but seems to be what is recommended by core
\Drupal\Core\Menu\MenuActiveTrail::getActiveLink:117
We can hide the error and hobble menu_position like this:
https://git.drupalcode.org/project/context/-/commit/45261a4e454887db279f...
Or be more forceful about the priority somehow maybe...
Any suggestions?
Comment #12
joelpittetHow's this for a solution? Moved the class from altering the service to a service decorator. Help from @cmlara and @BradJones via slack.
Comment #13
joelpittetRe-titling
Comment #15
joelpittetComment #16
joelpittetWhoops, forgot to include the deleted service provider.
Comment #17
joelpittetThe
CacheCollector
theMenuActiveTrail
extends from is pretty tightly coupled so I extended from that as well (saves the implementation of the public methods in the decorated class).Comment #18
joelpittetForgot need routeMatch service, this is now working locally from some testing.
Comment #20
joelpittetI've committed this to the dev branch for a new release soon.