You are here

protected function WorkflowTypeBase::getNextWeight in Drupal 8

Same name and namespace in other branches
  1. 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.

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\Plugin

Code

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