You are here

public function PredefinedStatesWorkflowTestType::getState in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php \Drupal\workflow_type_test\Plugin\WorkflowType\PredefinedStatesWorkflowTestType::getState()
  2. 9 core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php \Drupal\workflow_type_test\Plugin\WorkflowType\PredefinedStatesWorkflowTestType::getState()

Gets a workflow state.

Parameters

string $state_id: The state's ID.

Return value

\Drupal\workflows\StateInterface The workflow state.

Throws

\InvalidArgumentException Thrown if $state_id does not exist.

Overrides WorkflowTypeBase::getState

File

core/modules/workflows/tests/modules/workflow_type_test/src/Plugin/WorkflowType/PredefinedStatesWorkflowTestType.php, line 41

Class

PredefinedStatesWorkflowTestType
Test workflow type.

Namespace

Drupal\workflow_type_test\Plugin\WorkflowType

Code

public function getState($state_id) {
  $states = $this
    ->getStates();
  if (!isset($states[$state_id])) {
    throw new \InvalidArgumentException("The state '{$state_id}' does not exist in workflow.'");
  }
  return $states[$state_id];
}