public function EnvKeyProvider::validateConfigurationForm in Key 8
Form validation handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides PluginFormInterface::validateConfigurationForm
File
- src/
Plugin/ KeyProvider/ EnvKeyProvider.php, line 73
Class
- EnvKeyProvider
- A key provider that allows a key to be stored in an environment variable.
Namespace
Drupal\key\Plugin\KeyProviderCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$key_provider_settings = $form_state
->getValues();
$env_variable = $key_provider_settings['env_variable'];
$key_value = getenv($env_variable);
// Does the env variable exist.
if (!$key_value) {
$form_state
->setErrorByName('env_variable', $this
->t('The environment variable does not exist or it is empty.'));
return;
}
}