You are here

protected function CookiesConfigService::getGroups in COOKiES Consent Management 1.0.x

Returns the complete groups config.

Return value

array Complete groups config

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to CookiesConfigService::getGroups()
CookiesConfigService::getCookiesConfig in src/Services/CookiesConfigService.php
Returns the complete formatted Cookies JSR configuration.

File

src/Services/CookiesConfigService.php, line 318

Class

CookiesConfigService
Services to handle module config and method for a rendered documentation.

Namespace

Drupal\cookies\Services

Code

protected function getGroups() {
  $service_entities = $this->entityTypeManager
    ->getStorage('cookies_service')
    ->loadByProperties([
    'status' => 1,
  ]);
  $services = [];
  foreach ($service_entities as $s_entity) {

    /** @var \Drupal\cookies\Entity\CookiesServiceEntity $s_entity */
    $group = $s_entity
      ->get('group');
    if (!isset($services[$group])) {
      $services[$group] = [
        "id" => $group,
        "services" => [],
        "weight" => $this
          ->getGroupWeight($group),
      ];
    }
    $services[$group]["services"][] = [
      "key" => $s_entity
        ->id(),
      "type" => $s_entity
        ->get('group'),
      "name" => $s_entity
        ->label(),
      "info" => $s_entity
        ->get('info'),
      "uri" => $s_entity
        ->get('url'),
      "needConsent" => $s_entity
        ->get('consent'),
    ];
  }
  uasort($services, [
    $this,
    "sortWeight",
  ]);
  return $services;
}