function WorkflowTypeBase::addState
Same name in other branches
- 8.9.x core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::addState()
- 10 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::addState()
- 11.x core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::addState()
Overrides WorkflowTypeInterface::addState
1 method overrides WorkflowTypeBase::addState()
- PredefinedStatesWorkflowTestType::addState in core/
modules/ workflows/ tests/ modules/ workflow_type_test/ src/ Plugin/ WorkflowType/ PredefinedStatesWorkflowTestType.php - Adds a state to the workflow.
File
-
core/
modules/ workflows/ src/ Plugin/ WorkflowTypeBase.php, line 116
Class
- WorkflowTypeBase
- A base class for Workflow type plugins.
Namespace
Drupal\workflows\PluginCode
public function addState($state_id, $label) {
if ($this->hasState($state_id)) {
throw new \InvalidArgumentException("The state '{$state_id}' already exists in workflow.");
}
if (preg_match(static::VALID_ID_REGEX, $state_id)) {
throw new \InvalidArgumentException("The state ID '{$state_id}' must contain only lowercase letters, numbers, and underscores");
}
$this->configuration['states'][$state_id] = [
'label' => $label,
'weight' => $this->getNextWeight($this->configuration['states']),
];
ksort($this->configuration['states']);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.