Skip to content
Snippets Groups Projects
Commit a3f5a0d6 authored by Liam Morland's avatar Liam Morland Committed by Kevin Paxman
Browse files

ISTWCMS-4960: Give default access to Webforms that have no access to create submissions

parent e5e1cee5
No related branches found
No related tags found
1 merge request!134ISTWCMS-4960: Use #access to remove parts of forms instead of unsetting them
......@@ -428,6 +428,29 @@ function uw_cfg_common_update_8103() {
}
/*
* Give default access to Webforms that have no access to create submissions.
*/
function uw_cfg_common_update_8104() {
$counter = 0;
$webforms = \Drupal::entityTypeManager()->getStorage('webform')->loadMultiple();
foreach ($webforms as $webform) {
$access = $webform->getAccessRules();
if (empty($access['create']['roles'])) {
$access['create']['roles'] = [
'anonymous',
'authenticated',
];
$webform->setAccessRules($access);
$webform->save();
$counter++;
}
}
return t('Set default access for @counter Webforms.', ['@counter' => $counter]);
}
/**
* Implements hook_update_dependencies().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment