class KeyProvider in Akamai 8.3
Wrapper around the optional key.provider service.
Hierarchy
- class \Drupal\akamai\KeyProvider implements KeyProviderInterface
Expanded class hierarchy of KeyProvider
1 string reference to 'KeyProvider'
1 service uses KeyProvider
File
- src/
KeyProvider.php, line 8
Namespace
Drupal\akamaiView source
class KeyProvider implements KeyProviderInterface {
/**
* The key repository service if valid.
*
* @var \Drupal\key\KeyRepositoryInterface|null
*/
protected $keyRepository;
/**
* Creates a new key provider service.
*
* @param mixed $key_repository
* Optional key.repository service (from key module).
*/
public function __construct($key_repository) {
$this->keyRepository = $key_repository;
}
/**
* {@inheritdoc}
*/
public function hasKeyRepository() {
return isset($this->keyRepository);
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function getKeys() {
if (!$this
->hasKeyRepository()) {
throw new \Exception('Missing key.repository service. Ensure key module is enabled.');
}
return $this->keyRepository
->getKeys();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
KeyProvider:: |
protected | property | The key repository service if valid. | |
KeyProvider:: |
public | function |
Retrieves a key from the key module. Overrides KeyProviderInterface:: |
|
KeyProvider:: |
public | function |
Retrieves all keys from the key module. Overrides KeyProviderInterface:: |
|
KeyProvider:: |
public | function |
Confirms if key.repository service exists. Overrides KeyProviderInterface:: |
|
KeyProvider:: |
public | function | Creates a new key provider service. |