You are here

protected function FormsSteps::getNextWeight in Forms Steps 8

Gets the weight for a new step or progress step.

Parameters

array $items: An array of steps where each item has a 'weight' key with a numeric value.

Return value

int The weight for a step in the array so that it has the highest weight.

2 calls to FormsSteps::getNextWeight()
FormsSteps::addProgressStep in src/Entity/FormsSteps.php
Adds a progress step to the forms_steps.
FormsSteps::addStep in src/Entity/FormsSteps.php
Adds a step to the forms_steps.

File

src/Entity/FormsSteps.php, line 786

Class

FormsSteps
FormsSteps configuration entity to persistently store configuration.

Namespace

Drupal\forms_steps\Entity

Code

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