You are here

public function FormsSteps::getNextStep in Forms Steps 8

Returns the next step to $step.

Parameters

\Drupal\forms_steps\Step $step: The current Step.

Return value

\Drupal\forms_steps\Step|null Returns the next Step or null if no next step found.

Overrides FormsStepsInterface::getNextStep

1 call to FormsSteps::getNextStep()
FormsSteps::getNextStepRoute in src/Entity/FormsSteps.php
Returns the next step route.

File

src/Entity/FormsSteps.php, line 251

Class

FormsSteps
FormsSteps configuration entity to persistently store configuration.

Namespace

Drupal\forms_steps\Entity

Code

public function getNextStep(Step $step) {
  $nextStep = NULL;
  foreach ($this
    ->getSteps() as $current_step) {
    if (is_null($nextStep)) {
      $nextStep = $current_step;
    }
    else {
      if ($nextStep
        ->weight() < $current_step
        ->weight()) {
        $nextStep = $current_step;
        if ($nextStep
          ->weight() > $step
          ->weight()) {
          break;
        }
      }
    }
  }
  if (is_null($nextStep)) {
    return NULL;
  }
  else {
    return $nextStep;
  }
}