You are here

public function CategoryStorageManager::getCookieCategoryNextWeight in EU Cookie Compliance (GDPR Compliance) 8

Same name and namespace in other branches
  1. 2.0.x src/CategoryStorageManager.php \Drupal\eu_cookie_compliance\CategoryStorageManager::getCookieCategoryNextWeight()

Determine the next highest weight.

Return value

int The next highest weight.

File

src/CategoryStorageManager.php, line 50

Class

CategoryStorageManager
The cookie category storage manager class.

Namespace

Drupal\eu_cookie_compliance

Code

public function getCookieCategoryNextWeight() {

  /** @var \Drupal\eu_cookie_compliance\Entity\CookieCategoryInterface[] $cookies */
  $cookies = $this
    ->loadMultiple();
  $weight = -10;
  foreach ($cookies as $cookie) {
    if ($cookie
      ->getWeight() > $weight) {
      $weight = $cookie
        ->getWeight();
    }
  }
  return $weight + 1;
}