Problem/Motivation

Currently there is no easy way to add an event listener that subscribes to all the transition events of all the workflows in the system.
A developer might want to subscribe to all transitions for example to handle default revisions/published status (our case) or to send notifications to the interested users.

Proposed resolution

Fire also a more generic event during the pre and post transition phases.
To keep backwards compatibility, leave in place the previous specific transition event.

Remaining tasks

None.

User interface changes

None.

API changes

No changes really, just added new "state_machine.pre_transition" and "state_machine.post_transition" events.

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sardara created an issue. See original summary.

sardara’s picture

Assigned: sardara » Unassigned
Status: Active » Needs review
FileSize
7.94 KB
bojanz’s picture

Status: Needs review » Needs work

Makes sense. Let's remove the $phase from the even though, it's pointless since you always know whether you subscribed to pre_transition or post_transition.

sardara’s picture

You are completely right, with the current implementation it doesn't make sense. I'm attaching the fix already that removes the $phase.
Just to be sure, do you think it's better to remove the $phase or to launch a single event (e.g. "state_machine.transition") for both phases?

sardara’s picture

Status: Needs work » Needs review
pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me, went through it with my fine comb but found no complaints :) Thanks!

mitrpaka’s picture

bojanz’s picture

Assigned: Unassigned » bojanz
Status: Reviewed & tested by the community » Needs work

Great job!

Let's also add a workflow-group-specific generic event, to handle the use case mentioned in #2894810: Fire events named after the destination state rather than the transition name (where we know only the end state).

  • bojanz committed 933ea12 on 8.x-1.x authored by sardara
    Issue #2832415 by sardara, bojanz: Fire generic events when transition...
bojanz’s picture

Status: Needs work » Fixed

Added $workflow_group . $phase events, updated the README. And committed!

Status: Fixed » Closed (fixed)

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