Problem/Motivation
The content_moderation module does not have a dependency on node.module, yet the controller for the content_moderation.admin_moderated_content route depends on the node entity type.
Steps to reproduce
- Install Drupal with minimal profile
- Install content_moderation module
- Uninstall node module
- Visit /admin/content/moderated
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of /app/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).
Proposed resolution
Add a module dependency on the content_moderation.admin_moderated_content
route and provide the local task via the DynamicLocalTasks deriver if the route exists.
Remaining tasks
Review and commit
User interface changes
Moderated content local task no longer appears if node module is not installed.
API changes
Added $router
parameter to \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks::__construct()
Data model changes
Release notes snippet
Issue fork drupal-3211072
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
mstrelan CreditAttribution: mstrelan commentedI tried adding
_module_dependencies: 'node'
to thecontent_moderation.admin_moderated_content
route but this results in thecontent_moderation.moderated_content
local task throwing an error that the route does not exist.Comment #4
mstrelan CreditAttribution: mstrelan commentedComment #5
mstrelan CreditAttribution: mstrelan commentedComment #6
mstrelan CreditAttribution: mstrelan commentedComment #8
larowlanJust one minor nitpick, other than that this looks really solid
Comment #9
Sam152 CreditAttribution: Sam152 as a volunteer and commentedAll looks very reasonable to me. Nice.
Comment #11
larowlanApplied this locally because the MR is against 9.2.x
Committed bb180f9 and pushed to 9.3.x. Thanks!
Because of the constructor change, which is allowed in a Plugin under our BC policy, this is too disruptive for backporting to 9.2.x
Added a change notice for the above
Comment #13
acbramley CreditAttribution: acbramley at PreviousNext for Service NSW commentedJust an FYI - this will cause sites that previously removed this local task via
hook_local_tasks_alter
to suddenly start displaying it.For whatever reason, it seems like derivatives are added AFTER the alter hook runs, which I find very odd.