diff --git a/src/Plugin/KeyProvider/SettingsProvider.php b/src/Plugin/KeyProvider/SettingsProvider.php new file mode 100644 index 0000000..c8686cf --- /dev/null +++ b/src/Plugin/KeyProvider/SettingsProvider.php @@ -0,0 +1,71 @@ + NULL, + ]; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state): array { + $form['settings_variable'] = [ + '#type' => 'textfield', + '#title' => $this->t('Settings variable'), + '#description' => $this->t('Name of the settings variable.'), + '#required' => TRUE, + '#default_value' => $this->getConfiguration()['settings_variable'], + ]; + return $form; + } + + /** + * {@inheritdoc} + */ + public function validateConfigurationForm(array &$form, FormStateInterface $form_state): void { + // There is nothing to validate. + } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void { + $this->setConfiguration($form_state->getValues()); + } + + /** + * {@inheritdoc} + */ + public function getKeyValue(KeyInterface $key): string { + return Settings::get($this->getConfiguration()['settings_variable'], ''); + } + +}