You are here

public function KeyRepository::getKeysByStorageMethod in Key 8

Get keys that use the specified storage method.

Storage method is an annotation of a key's key provider.

Parameters

string $storage_method: The storage method of the key provider.

Return value

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

Overrides KeyRepositoryInterface::getKeysByStorageMethod

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

File

src/KeyRepository.php, line 84

Class

KeyRepository
Provides a repository for Key configuration entities.

Namespace

Drupal\key

Code

public function getKeysByStorageMethod($storage_method) {
  $key_providers = array_filter($this->keyProviderManager
    ->getDefinitions(), function ($definition) use ($storage_method) {
    return $definition['storage_method'] == $storage_method;
  });
  $keys = [];
  foreach ($key_providers as $key_provider) {
    $keys = array_merge($keys, $this
      ->getKeysByProvider($key_provider['id']));
  }
  return $keys;
}