You are here

public function KeyRepository::getKeysByTypeGroup in Key 8

Get keys that use a key type in the specified group.

Group is an annotation of a key's key type.

Parameters

string $type_group: The key type group on which to filter.

Return value

\Drupal\key\Entity\Key[] An array of key objects indexed by their ids.

Overrides KeyRepositoryInterface::getKeysByTypeGroup

1 call to KeyRepository::getKeysByTypeGroup()
KeyRepository::getKeyNamesAsOptions in src/KeyRepository.php
Get an array of key names, useful as options in form fields.

File

src/KeyRepository.php, line 99

Class

KeyRepository
Provides a repository for Key configuration entities.

Namespace

Drupal\key

Code

public function getKeysByTypeGroup($type_group) {
  $key_types = array_filter($this->keyTypeManager
    ->getDefinitions(), function ($definition) use ($type_group) {
    return $definition['group'] == $type_group;
  });
  $keys = [];
  foreach ($key_types as $key_type) {
    $keys = array_merge($keys, $this
      ->getKeysByType($key_type['id']));
  }
  return $keys;
}