public function FormsSteps::addProgressStep in Forms Steps 8
Adds a progress step to the forms_steps.
Parameters
string $progress_step_id: The progress step's ID.
string $label: The progress step's label.
array $routes: The progress step's active routes.
string $link: The progress step's link.
array $link_visibility: The progress step's link visibility.
Return value
\Drupal\forms_steps\FormsStepsInterface The forms_steps entity.
Overrides FormsStepsInterface::addProgressStep
File
- src/Entity/ FormsSteps.php, line 212 
Class
- FormsSteps
- FormsSteps configuration entity to persistently store configuration.
Namespace
Drupal\forms_steps\EntityCode
public function addProgressStep($progress_step_id, $label, array $routes, $link, array $link_visibility) {
  if (isset($this->progress_steps[$progress_step_id])) {
    throw new \InvalidArgumentException("The Progress Step '{$progress_step_id}' already exists in the forms steps '{$this->id()}'");
  }
  if (preg_match('/[^a-z0-9_]+/', $progress_step_id)) {
    throw new \InvalidArgumentException("The Progress Step ID '{$progress_step_id}' must contain only lowercase letters, numbers, and underscores");
  }
  $this->progress_steps[$progress_step_id] = [
    'label' => $label,
    'weight' => $this
      ->getNextWeight($this->progress_steps),
    'routes' => $routes,
    'link' => $link,
    'link_visibility' => $link_visibility,
  ];
  ksort($this->progress_steps);
  return $this;
}