public function WorkflowTypeBase::setTransitionWeight in Drupal 10
Same name and namespace in other branches
- 8 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::setTransitionWeight()
- 9 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::setTransitionWeight()
File
- core/
modules/ workflows/ src/ Plugin/ WorkflowTypeBase.php, line 395
Class
- WorkflowTypeBase
- A base class for Workflow type plugins.
Namespace
Drupal\workflows\PluginCode
public function setTransitionWeight($transition_id, $weight) {
if (!$this
->hasTransition($transition_id)) {
throw new \InvalidArgumentException("The transition '{$transition_id}' does not exist in workflow.");
}
if (!is_numeric($weight)) {
$label = $this
->getTransition($transition_id)
->label();
throw new \InvalidArgumentException("The weight '{$weight}' must be numeric for transition '{$label}'.");
}
$this->configuration['transitions'][$transition_id]['weight'] = $weight;
return $this;
}