Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
geocoder
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
geocoder
Merge requests
!60
Add a way to skip geocoding using runtime parameters.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add a way to skip geocoding using runtime parameters.
issue/geocoder-3301512:3301512-posibility-to-skip-geocoding
into
8.x-4.x
Overview
0
Commits
4
Pipelines
5
Changes
3
Merged
Andrei Mateescu
requested to merge
issue/geocoder-3301512:3301512-posibility-to-skip-geocoding
into
8.x-4.x
4 months ago
Overview
0
Commits
4
Pipelines
5
Changes
3
Expand
Closes
#3301512
0
0
Merge request reports
Compare
8.x-4.x
version 4
5e819f53
4 months ago
version 3
caadd518
4 months ago
version 2
a4bb3ba9
4 months ago
version 1
65cc52a4
4 months ago
8.x-4.x (base)
and
latest version
latest version
5e819f53
4 commits,
4 months ago
version 4
5e819f53
4 commits,
4 months ago
version 3
caadd518
3 commits,
4 months ago
version 2
a4bb3ba9
2 commits,
4 months ago
version 1
65cc52a4
1 commit,
4 months ago
3 files
+
75
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
modules/geocoder_field/src/EventSubscriber/WorkspacePublishingSubscriber.php
0 → 100644
+
62
−
0
Options
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\geocoder_field\EventSubscriber
;
use
Drupal\workspaces\Event\WorkspacePostPublishEvent
;
use
Drupal\workspaces\Event\WorkspacePrePublishEvent
;
use
Drupal\workspaces\Event\WorkspacePublishEvent
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
use
Symfony\Component\HttpFoundation\RequestStack
;
/**
* Event subscriber to respond to workspace publishing events.
*
* The geocoding operations from geocoder_field_entity_presave() can be very
* expensive when updating many entities at once. Workspace publishing doesn't
* change any field data, it only re-saves the latest workspace-specific
* revision and sets it as the default one, so there is no need to update
* geocoding data.
*
* @see geocoder_field_entity_presave()
*/
class
WorkspacePublishingSubscriber
implements
EventSubscriberInterface
{
public
function
__construct
(
protected
RequestStack
$requestStack
,
)
{}
/**
* {@inheritdoc}
*/
public
static
function
getSubscribedEvents
():
array
{
if
(
!
class_exists
(
WorkspacePublishEvent
::
class
))
{
return
[];
}
return
[
WorkspacePrePublishEvent
::
class
=>
[
'onPrePublish'
],
WorkspacePostPublishEvent
::
class
=>
[
'onPostPublish'
],
];
}
/**
* Adds a custom request attribute to prevent geocoding updates.
*/
public
function
onPrePublish
():
void
{
if
(
$request
=
$this
->
requestStack
->
getCurrentRequest
())
{
$request
->
attributes
->
set
(
'geocoder_presave_disabled'
,
TRUE
);
}
}
/**
* Removes the custom request attribute.
*/
public
function
onPostPublish
():
void
{
if
(
$request
=
$this
->
requestStack
->
getCurrentRequest
())
{
$request
->
attributes
->
remove
(
'geocoder_presave_disabled'
);
}
}
}
Loading