You are here

public function WorkflowTypeBase::getStates in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getStates()
  2. 10 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getStates()

Gets state objects for the provided state IDs.

Parameters

string[] $state_ids: A list of state IDs to get. If NULL then all states will be returned.

Return value

\Drupal\workflows\StateInterface[] An array of workflow states, keyed by state IDs.

Throws

\InvalidArgumentException Thrown if $state_ids contains a state ID that does not exist.

Overrides WorkflowTypeInterface::getStates

1 call to WorkflowTypeBase::getStates()
WorkflowTypeBase::getInitialState in core/modules/workflows/src/Plugin/WorkflowTypeBase.php
Gets the initial state for the workflow.
1 method overrides WorkflowTypeBase::getStates()
PredefinedStatesWorkflowTestType::getStates in core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php
Gets state objects for the provided state IDs.

File

core/modules/workflows/src/Plugin/WorkflowTypeBase.php, line 141

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

public function getStates($state_ids = NULL) {
  if ($state_ids === NULL) {
    $state_ids = array_keys($this->configuration['states']);
  }

  /** @var \Drupal\workflows\StateInterface[] $states */
  $states = array_combine($state_ids, array_map([
    $this,
    'getState',
  ], $state_ids));
  return static::labelWeightMultisort($states);
}