Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
12
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Merge requests
!280
ISTWCMS-5680: Adding webform pre save fix for ohana branch.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
ISTWCMS-5680: Adding webform pre save fix for ohana branch.
feature/ISTWCMS-5680-ibiki-ohana-webform-migration-fix
into
1.1.x
Overview
0
Commits
1
Pipelines
0
Changes
2
Merged
Igor Biki
requested to merge
feature/ISTWCMS-5680-ibiki-ohana-webform-migration-fix
into
1.1.x
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
2
Expand
👍
0
👎
0
Merge request reports
Compare
1.1.x
version 2
f753d52f
2 years ago
version 1
c153b06a
2 years ago
1.1.x (base)
and
latest version
latest version
f753d52f
1 commit,
2 years ago
version 2
f753d52f
1 commit,
2 years ago
version 1
c153b06a
1 commit,
2 years ago
2 files
+
57
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/EventSubscriber/UwWebformEventSubscriber.php
0 → 100644
+
53
−
0
Options
<?php
namespace
Drupal\uw_cfg_common\EventSubscriber
;
use
Drupal\core_event_dispatcher
\EntityHookEvents
;
use
Drupal\core_event_dispatcher
\Event\Entity\EntityPresaveEvent
;
use
Drupal\webform\WebformInterface
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
/**
* Fixes roles permission for submission create for webforms.
*/
class
UwWebformEventSubscriber
implements
EventSubscriberInterface
{
/**
* {@inheritDoc}
*/
public
static
function
getSubscribedEvents
():
array
{
return
[
EntityHookEvents
::
ENTITY_PRE_SAVE
=>
'preSave'
,
];
}
/**
* Entity pre save dispatched event.
*
* @param \Drupal\core_event_dispatcher\Event\Entity\EntityPresaveEvent $event
* Event object.
*/
public
function
preSave
(
EntityPresaveEvent
$event
):
void
{
$entity
=
$event
->
getEntity
();
if
(
$entity
->
bundle
()
===
'webform'
)
{
/** @var \Drupal\webform\Entity\Webform $entity */
$access_rules
=
$entity
->
getAccessRules
();
// Update webform submission access roles to be anonymous and
// authenticated. This will be done on EVERY webform save.
// Fixes migration issue with webforms. Once migration is updated and
// fixed, this code is no longer needed and can be removed.
$access_rules
[
'create'
][
'roles'
]
=
[
'anonymous'
,
'authenticated'
,
];
$entity
->
setAccessRules
(
$access_rules
);
// Setting default access denied handler.
$entity
->
setSetting
(
'form_access_denied'
,
WebformInterface
::
ACCESS_DENIED_PAGE
);
}
}
}
Loading