Browse Source

added a config schema update the settings form and add a update hook to remove the the unused config settings

9.x-3.0
Paul Pound 1 week ago
parent
commit
a441faf8f9
  1. 28
      config/schema/upei_roblib_ill.schema.yml
  2. 3
      src/Form/RoblibIllSettingsForm.php
  3. 11
      upei_roblib_ill.install

28
config/schema/upei_roblib_ill.schema.yml

@ -0,0 +1,28 @@
upei_roblib_ill.settings:
type: config_object
label: 'UPEI Roblib ILL settings'
mapping:
ill_library_symbol:
type: string
label: 'Your ILL Library Symbol'
ill_doi_openurl_pid:
type: string
label: 'OpenURL PID'
ill_contact_email:
type: string
label: 'Contact Email'
ill_contact_phone:
type: string
label: 'Contact Phone Number'
rapid_ill_username:
type: string
label: 'RapidILL Username'
rapid_ill_password:
type: string
label: 'RapidILL Password'
rapid_ill_code:
type: string
label: 'RapidILL Rapid Code'
rapid_ill_branch_name:
type: string
label: 'RapidILL Branch Name'

3
src/Form/RoblibIllSettingsForm.php

@ -121,10 +121,7 @@ class RoblibIllSettingsForm extends FormBase
public function submitForm(array &$form, FormStateInterface $form_state)
{
$config = \Drupal::configFactory()->getEditable('upei_roblib_ill.settings');
$config->set('ill_add_url', $form_state->getValue('ill_add_url'))->save();
$config->set('ill_auth_url', $form_state->getValue('ill_auth_url'))->save();
$config->set('ill_library_symbol', $form_state->getValue('ill_library_symbol'))->save();
$config->set('ill_relais_key', $form_state->getValue('ill_relais_key'))->save();
$config->set('ill_doi_openurl_pid', $form_state->getValue('ill_doi_openurl_pid'))->save();
$config->set('ill_contact_email', $form_state->getValue('ill_contact_email'))->save();
$config->set('ill_contact_phone', $form_state->getValue('ill_contact_phone'))->save();

11
upei_roblib_ill.install

@ -16,6 +16,17 @@ function upei_roblib_ill_update_7100() {
);
}
/**
* Remove obsolete Relais configuration keys.
*/
function upei_roblib_ill_update_9301() {
\Drupal::configFactory()->getEditable('upei_roblib_ill.settings')
->clear('ill_add_url')
->clear('ill_auth_url')
->clear('ill_relais_key')
->save();
}
/**
* Implements hook_schema().
*/

Loading…
Cancel
Save