You are here

private function BusinessRuleForm::generateItemWeight in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Form/BusinessRuleForm.php \Drupal\business_rules\Form\BusinessRuleForm::generateItemWeight()

Generate the item weight.

Parameters

string $settings_type: The settings type.

int $weight: The item weight.

Return value

int The generated weight.

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

File

src/Form/BusinessRuleForm.php, line 433

Class

BusinessRuleForm
Class BusinessRuleForm.

Namespace

Drupal\business_rules\Form

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);
  }
}