Problem/Motivation

I'm trying to override the content_moderation.state_transition_validation to use my own class in order to provide a temporary solution to #2922266: Add permission to access all workflow transitions. This results in errors like:

TypeError: Argument 9 passed to Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget::__construct() must be an instance of Drupal\content_moderation\StateTransitionValidation, instance of Drupal\mymodule\StateTransitionValidation given, called in /var/www/docroot/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php on line 101 in Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget->__construct() (line 80 of core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php).

Proposed resolution

Any classes in content_moderation should use StateTransitionValidationInterface rather than StateTransitionValidation.

./tests/src/Unit/StateTransitionValidationTest.php
./src/Form/EntityModerationForm.php
./src/Plugin/Field/FieldWidget/ModerationStateWidget.php

Remaining tasks

Write a patch.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

mstef created an issue. See original summary.

mstef’s picture

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

Good catch!

catch’s picture

Version: 8.4.x-dev » 8.5.x-dev
Status: Reviewed & tested by the community » Needs work

Doesn't apply to 8.5.x

timmillwood’s picture

Status: Needs work » Needs review
Issue tags: +Workflow Initiative
FileSize
4.3 KB

Re-roll for 8.5.x

Sam152’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.5.x, thanks!

  • catch committed 2bd52f5 on 8.5.x
    Issue #2922285 by mstef, timmillwood: Classes should use...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mstef’s picture

mstef’s picture

FileSize
4.25 KB

Here's a patch for 8.4-dev for reference if any one needs it.

jhedstrom’s picture

This would be nice to backport to 8.4.x. Otherwise modules that need to decorate this service (#2906085: Content moderation integration: transition permissions and latest version access for instance) get fatal errors:

TypeError: Argument 9 passed to Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget::__construct() must be an instance of Drupal\content_moderation\StateTransitionValidation, instance of Drupal\group\StateTransitionValidation