function WorkflowTypeBase::setTransitionWeight

Same name and namespace in other branches
  1. 9 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::setTransitionWeight()
  2. 8.9.x core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::setTransitionWeight()
  3. 10 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::setTransitionWeight()

Overrides WorkflowTypeInterface::setTransitionWeight

File

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

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.