You are here

private function LoopThroughFieldVariable::generateItemWeight in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/BusinessRulesAction/LoopThroughFieldVariable.php \Drupal\business_rules\Plugin\BusinessRulesAction\LoopThroughFieldVariable::generateItemWeight()

Generate the item weight.

Parameters

string $settings_type: The settings type: success|fail.

int $weight: The weight.

Return value

int The generated weight

1 call to LoopThroughFieldVariable::generateItemWeight()
LoopThroughFieldVariable::formItems in src/Plugin/BusinessRulesAction/LoopThroughFieldVariable.php
Provide the form fields for add Business Rule's Items.

File

src/Plugin/BusinessRulesAction/LoopThroughFieldVariable.php, line 272

Class

LoopThroughFieldVariable
Class LoopThroughFieldVariable.

Namespace

Drupal\business_rules\Plugin\BusinessRulesAction

Code

private function generateItemWeight($settings_type, $weight) {
  if (!isset($this->usedWeight[$settings_type])) {
    $this->usedWeight[$settings_type][] = $weight;
    return $weight;
  }
  if (!in_array($weight, $this->usedWeight[$settings_type])) {
    $this->usedWeight[$settings_type][] = $weight;
    return $weight;
  }
  else {
    $weight++;
    return $this
      ->generateItemWeight($settings_type, $weight);
  }
}