You are here

public function FormsStepsManager::getPreviousStepRoute in Forms Steps 8

Get the forms_steps previous route step.

Parameters

mixed $route_name: Current route name.

Return value

null|string Returns the previous route.

File

src/Service/FormsStepsManager.php, line 108

Class

FormsStepsManager
Class FormsStepsManager.

Namespace

Drupal\forms_steps\Service

Code

public function getPreviousStepRoute($route_name) {
  $previousRoute = NULL;
  $matches = self::getRouteParameters($route_name);
  if ($matches) {

    /** @var \Drupal\forms_steps\Entity\FormsSteps $formsSteps */
    $formsSteps = FormsSteps::load($matches[1]);
    if (!$formsSteps) {
      return $previousRoute;
    }
    $step = $formsSteps
      ->getStep($matches[2]);
    if (!$step) {
      return $previousRoute;
    }
    return $formsSteps
      ->getPreviousStepRoute($step);
  }
}