You are here

public function WorkflowTypeBase::getState in Drupal 10

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

File

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

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

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