View source
<?php
function lockr_update_8301() {
$configFactory = \Drupal::service('config.factory');
$state = \Drupal::service('state');
$config = $configFactory
->getEditable('lockr.settings');
if (!$config
->get('region') && ($region = $state
->get('lockr.region'))) {
$config
->set('region', $region);
}
if ($config
->get('custom')) {
$config
->set('cert_path', $config
->get('custom_cert'));
$config
->clear('custom_cert');
}
elseif ($state
->get('lockr.custom', FALSE)) {
$config
->set('custom', TRUE);
$config
->set('cert_path', $state
->get('lockr.cert'));
}
$config
->save();
}
function lockr_update_8302() {
$key_repository = \Drupal::service('key.repository');
$configFactory = \Drupal::service('config.factory');
$keys = $key_repository
->getKeysByProvider('lockr');
$config = $configFactory
->getEditable('lockr.secret_info');
foreach ($keys as $key) {
$name = $key
->id();
if ($config
->get($name)) {
continue;
}
$provider = $key
->getKeyProvider();
$key_config = $provider
->getConfiguration();
if (isset($key_config['encoded'])) {
$config
->set("{$name}.wrapping_key", $key_config['encoded']);
}
}
$config
->save();
}