function WorkflowTypeBase::getNextWeight
Same name and namespace in other branches
- 9 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getNextWeight()
- 10 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getNextWeight()
- 11.x core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getNextWeight()
Gets the weight for a new state or transition.
Parameters
array $items: An array of states or transitions information where each item has a 'weight' key with a numeric value.
Return value
int The weight for a new item in the array so that it has the highest weight.
2 calls to WorkflowTypeBase::getNextWeight()
- WorkflowTypeBase::addState in core/
modules/ workflows/ src/ Plugin/ WorkflowTypeBase.php - Adds a state to the workflow.
- WorkflowTypeBase::addTransition in core/
modules/ workflows/ src/ Plugin/ WorkflowTypeBase.php - Adds a transition to the workflow.
File
-
core/
modules/ workflows/ src/ Plugin/ WorkflowTypeBase.php, line 458
Class
- WorkflowTypeBase
- A base class for Workflow type plugins.
Namespace
Drupal\workflows\PluginCode
protected function getNextWeight(array $items) {
return array_reduce($items, function ($carry, $item) {
return max($carry, $item['weight'] + 1);
}, 0);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.