Skip to content

Commit

Permalink
simplified code in method getSteps
Browse files Browse the repository at this point in the history
  • Loading branch information
craue committed Oct 6, 2014
1 parent df39bc6 commit c2e6c82
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions Form/FormFlow.php
Expand Up @@ -764,26 +764,20 @@ public function getStep($stepNumber) {
* {@inheritDoc}
*/
public function getSteps() {
// The steps have been loaded already.
if ($this->steps !== null) {
return $this->steps;
}

// There are no listeners on the event at all, load from configuration.
if (!$this->hasListeners(FormFlowEvents::GET_STEPS)) {
$this->steps = $this->createStepsFromConfig($this->loadStepsConfig());
if ($this->steps === null) {
if ($this->hasListeners(FormFlowEvents::GET_STEPS)) {
$event = new GetStepsEvent($this);
$this->eventDispatcher->dispatch(FormFlowEvents::GET_STEPS, $event);

return $this->steps;
}
// A listener has provided the steps for this flow.
if ($event->isPropagationStopped()) {
$this->steps = $event->getSteps();

$event = new GetStepsEvent($this);
$this->eventDispatcher->dispatch(FormFlowEvents::GET_STEPS, $event);
return $this->steps;
}
}

// A listener has provided the steps for this flow.
if ($event->isPropagationStopped()) {
$this->steps = $event->getSteps();
// There are listeners, but none created the steps for this flow, so fallback to config.
} else {
// There are either no listeners on the event at all or none created the steps for this flow, so load from configuration.
$this->steps = $this->createStepsFromConfig($this->loadStepsConfig());
}

Expand Down

0 comments on commit c2e6c82

Please sign in to comment.