Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Workflow guard EventSubscriber dispatch all event, but not correct transition #23677

Copy link
Copy link
Closed
@Regnoy

Description

@Regnoy
Issue body actions
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 3.5

workflow

offer:
        type: 'workflow'
        marking_store:
          type: 'single_state'
        supports:
          - OfferBundle\Entity\Offer
        places:
          - draft
          - published
          - published_public
          - published_private
          - published_failed
          - unpublished
          - blocked
          - rejected
        transitions:
          published:
            from: [draft, unpublished]
            to: published
          published_public:
            from: published
            to: published_public
          published_private:
            from: published
            to: published_private
          published_failed:
            from: published
            to: published_failed
          unpublished:
            from: published
            to: unpublished
          rejected:
            from: [published, unpublished]
            to: rejected
class OfferWorkflowListener implements EventSubscriberInterface {


  public function guardPublishPrivate(GuardEvent $event){
    var_dump("guardPublishPrivate");
  }
  public function guardPublishPublic(GuardEvent $event){
    var_dump("guardPublishPublic");
  }
  public function guardPublishFailed(GuardEvent $event){
     var_dump("guardPublishFailed");
  }
  public static function getSubscribedEvents() {
    return [
      'workflow.offer.guard.published_private' => 'guardPublishPrivate',
      'workflow.offer.guard.published_public' => 'guardPublishPublic',
      'workflow.offer.guard.published_failed' => 'guardPublishFailed',
    ];
  }
}

after call workflow->can($offer, 'published_private')

output is
guardPublishPublic
guardPublishPrivate
guardPublishFailed

but must be unique

guardPublishPrivate method call.

But is must only one event there is transition not all event where workflow have "from:published"

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.