diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 1766e66fe3fb1..a4ffe6027efe8 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -239,6 +239,10 @@ public function testApplyWithEventDispatcher() 'workflow.workflow_name.enter', 'workflow.workflow_name.enter.b', 'workflow.workflow_name.enter.c', + 'workflow.entered', + 'workflow.workflow_name.entered', + 'workflow.workflow_name.entered.b', + 'workflow.workflow_name.entered.c', // Following events are fired because of announce() method 'workflow.guard', 'workflow.workflow_name.guard', diff --git a/src/Symfony/Component/Workflow/Workflow.php b/src/Symfony/Component/Workflow/Workflow.php index 8fc64e979d3b8..2f98203470183 100644 --- a/src/Symfony/Component/Workflow/Workflow.php +++ b/src/Symfony/Component/Workflow/Workflow.php @@ -140,6 +140,8 @@ public function apply($subject, $transitionName) $this->markingStore->setMarking($subject, $marking); + $this->entered($subject, $transition, $marking); + $this->announce($subject, $transition, $marking); } @@ -270,6 +272,22 @@ private function enter($subject, Transition $transition, Marking $marking) } } + private function entered($subject, Transition $transition, Marking $marking) + { + if (null === $this->dispatcher) { + return; + } + + $event = new Event($subject, $marking, $transition); + + $this->dispatcher->dispatch('workflow.entered', $event); + $this->dispatcher->dispatch(sprintf('workflow.%s.entered', $this->name), $event); + + foreach ($transition->getTos() as $place) { + $this->dispatcher->dispatch(sprintf('workflow.%s.entered.%s', $this->name, $place), $event); + } + } + private function announce($subject, Transition $initialTransition, Marking $marking) { if (null === $this->dispatcher) {