You are here

public function FormsSteps::getProgressSteps in Forms Steps 8

Gets progress step objects for the provided progress step IDs.

Parameters

string[] $progress_step_ids: A list of progress step IDs to get. If NULL then all progress steps will be returned.

Return value

\Drupal\forms_steps\ProgressStepInterface[] An array of forms_steps progress steps.

Throws

\InvalidArgumentException Thrown if $progress_step_ids contains a progress step ID that does not exist.

Overrides FormsStepsInterface::getProgressSteps

File

src/Entity/FormsSteps.php, line 375

Class

FormsSteps
FormsSteps configuration entity to persistently store configuration.

Namespace

Drupal\forms_steps\Entity

Code

public function getProgressSteps(array $progress_step_ids = NULL) {
  if ($progress_step_ids === NULL) {
    $progress_step_ids = array_keys($this->progress_steps);
  }

  /** @var \Drupal\forms_steps\ProgressStepInterface[] $progress_steps */
  $progress_steps = array_combine($progress_step_ids, array_map([
    $this,
    'getProgressStep',
  ], $progress_step_ids));
  if (count($progress_steps) > 1) {

    // Sort Steps by weight and then label.
    $weights = $labels = [];
    foreach ($progress_steps as $id => $progress_step) {
      $weights[$id] = $progress_step
        ->weight();
      $labels[$id] = $progress_step
        ->label();
    }
    array_multisort($weights, SORT_NUMERIC, SORT_ASC, $labels, SORT_NATURAL, SORT_ASC);
    $progress_steps = array_replace($weights, $progress_steps);
  }
  return $progress_steps;
}