You are here

protected function WorkflowTypeBase::getNextWeight in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/workflows/src/Plugin/WorkflowTypeBase.php \Drupal\workflows\Plugin\WorkflowTypeBase::getNextWeight()
  2. 9 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.

File

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

Class

WorkflowTypeBase
A base class for Workflow type plugins.

Namespace

Drupal\workflows\Plugin

Code

protected function getNextWeight(array $items) {
  return array_reduce($items, function ($carry, $item) {
    return max($carry, $item['weight'] + 1);
  }, 0);
}