Skip to content
Snippets Groups Projects

Additional form IDs are now correctly saved as arrays, not strings.

Files
2
+ 30
0
@@ -27,3 +27,33 @@ function readonlymode_update_8001() {
'site_readonly_forms_viewonly' => 'forms.additional.view',
]);
}
/**
* Convert any existing additional form configuration from strings to arrays.
*/
function readonlymode_update_8002() {
/** @var \Drupal\Core\Config\Config */
$config = \Drupal::configFactory()->getEditable('readonlymode.settings');
foreach (['forms.additional.edit', 'forms.additional.view'] as $key) {
/** @var string|array */
$value = $config->get($key);
if (!\is_string($value)) {
continue;
}
$config->set($key, \preg_split('/\s+/m', $value));
}
$config->save();
// Delete the cached configuration in case updates were run via Drush with the
// '--no-cache-clear' flag so that the updated configuration gets used
// immediately.
\Drupal::cache('config')->delete('readonlymode.settings');
}
Loading