Skip to content

[Workflow] Add a validator to check / enforce state change restrictions #23863

@dkarlovi

Description

@dkarlovi
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version latest

If you have an entity with a state machine attached, you can still just set any state as current and save if you're not using apply().

It would make sense to add a validator specifically enforcing the attached state machine, it would:

  1. figure out if the state being set is actually a valid state at all
  2. figure out if the state being set is a valid state from current state
  3. (this is debateable) try to apply the state so event listeners are able to block the transition?

It would allow for more easier integration of the component into common workflows, IMO.

Edit: if 3) is considered, listeners should probably be able to provide an explanation why they've blocked the transition (ConstraintViolationInterface or similar?)

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions