You are here

public function KeyProvider::getKey in Akamai 8.3

Retrieves a key from the key module.

Parameters

string $key: The id of the key to retrieve.

Return value

string|null The key value on success, NULL on failure.

Throws

\Exception Indicates the key.repository service was not found.

Overrides KeyProviderInterface::getKey

File

src/KeyProvider.php, line 37

Class

KeyProvider
Wrapper around the optional key.provider service.

Namespace

Drupal\akamai

Code

public function getKey($key) {
  if (!$this
    ->hasKeyRepository()) {
    throw new \Exception('Missing key.repository service. Ensure key module is enabled.');
  }
  $key_entity = $this->keyRepository
    ->getKey($key);
  if (isset($key_entity)) {
    return $key_entity
      ->getKeyValue();
  }
  return NULL;
}