public function CategoryStorageManager::getCookieCategories in EU Cookie Compliance (GDPR Compliance) 8
Same name and namespace in other branches
- 2.0.x src/CategoryStorageManager.php \Drupal\eu_cookie_compliance\CategoryStorageManager::getCookieCategories()
Load and return all active cookie categories.
Return value
array|\Drupal\Core\Entity\EntityInterface[] The loaded cookie categories.
File
- src/
CategoryStorageManager.php, line 18
Class
- CategoryStorageManager
- The cookie category storage manager class.
Namespace
Drupal\eu_cookie_complianceCode
public function getCookieCategories() {
$categories = [];
/** @var \Drupal\eu_cookie_compliance\Entity\CookieCategoryInterface[] $category_entities */
$category_entities = $this
->loadMultiple();
foreach ($category_entities as $category_entity) {
// Added this check to allow people to use domain access to change
// the categories per domain. Unfortunately you can't create new
// config entities only for a specific domain, but you can create
// them for the normal site, and then set the status to false
// and override it for the domain you want it to show up in, setting
// the status to true for that domain.
// Not ideal, but after the initial work setting it up it seems to
// work fine.
if ($category_entity
->get('status')) {
$categories[$category_entity
->id()] = $category_entity
->toArray();
}
}
// Order the categories by their weight.
uasort($categories, function ($a, $b) {
return $a['weight'] - $b['weight'];
});
return $categories;
}