Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
layout_builder_st
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
layout_builder_st
Merge requests
!10
Fix Layout translation form reports unsaved changes and becomes stale + call undefined method idDefaultTranslation()
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Fix Layout translation form reports unsaved changes and becomes stale + call undefined method idDefaultTranslation()
issue/layout_builder_st-3222423:3222423-unsaved-changes
into
8.x-1.x
Overview
0
Commits
1
Pipelines
0
Changes
2
Open
Francisco Ruiz-Alejos
requested to merge
issue/layout_builder_st-3222423:3222423-unsaved-changes
into
8.x-1.x
11 months ago
Overview
0
Commits
1
Pipelines
0
Changes
2
Expand
Refs:
#3222423
-unsaved-changes
Closes
#3222423
0
0
Merge request reports
Compare
8.x-1.x
8.x-1.x (HEAD)
and
latest version
latest version
751a7d9b
1 commit,
11 months ago
2 files
+
42
−
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/PrepareLayout.php
0 → 100644
+
37
−
0
Options
<?php
namespace
Drupal\layout_builder_st\EventSubscriber
;
use
Drupal\layout_builder
\Event\PrepareLayoutEvent
;
use
Drupal\layout_builder
\EventSubscriber\PrepareLayout
as
CorePrepareLayout
;
/**
* Overrides the core PrepareLayout event subscriber.
*/
class
PrepareLayout
extends
CorePrepareLayout
{
/**
* {@inheritdoc}
*/
public
function
onPrepareLayout
(
PrepareLayoutEvent
$event
)
{
$section_storage
=
$event
->
getSectionStorage
();
// If the layout is being edited in its source language, let core
// layout_builder do its standard handling of the event.
if
(
method_exists
(
$section_storage
,
'isDefaultTranslation'
))
{
if
(
$section_storage
->
isDefaultTranslation
())
{
return
parent
::
onPrepareLayout
(
$event
);
}
}
// If a symmetric translation is being edited, do not add the section
// storage to the tempstore. This can result in the symmetric translation
// getting stuck in the "you have unsaved changes" state after the Layout
// Builder form is visited, even if no changes are made. Just show the
// unsaved changes message if needed.
if
(
$this
->
layoutTempstoreRepository
->
has
(
$section_storage
))
{
$this
->
messenger
->
addWarning
(
$this
->
t
(
'You have unsaved changes.'
));
}
}
}
Loading