public function ConfigKeyProvider::setKeyValue in Key 8
Sets the value of a key.
Parameters
\Drupal\key\KeyInterface $key: The key whose value will be set.
string $key_value: The key value.
Return value
bool TRUE if successful, FALSE if unsuccessful.
Overrides KeyProviderSettableValueInterface::setKeyValue
File
- src/
Plugin/ KeyProvider/ ConfigKeyProvider.php, line 84
Class
- ConfigKeyProvider
- Adds a key provider that allows a key to be stored in configuration.
Namespace
Drupal\key\Plugin\KeyProviderCode
public function setKeyValue(KeyInterface $key, $key_value) {
if (isset($this->configuration['base64_encoded']) && $this->configuration['base64_encoded'] == TRUE) {
$key_value = base64_encode($key_value);
}
$this->configuration['key_value'] = $key_value;
if (isset($this->configuration['key_value'])) {
return TRUE;
}
else {
throw new KeyValueNotSetException();
}
}