Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
recurring_events
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
recurring_events
Commits
61067b35
Commit
61067b35
authored
1 year ago
by
Owen Bush
Committed by
Andrii Podanenko
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve issue with creating translations and displaying the event instances
parent
6bdc2517
No related branches found
No related tags found
1 merge request
!69
Issue #3318666: Event instances are not created with the correct language
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/EventCreationService.php
+10
-1
10 additions, 1 deletion
src/EventCreationService.php
src/EventUserTrait.php
+11
-0
11 additions, 0 deletions
src/EventUserTrait.php
src/Plugin/ComputedField/EventInstances.php
+1
-2
1 addition, 2 deletions
src/Plugin/ComputedField/EventInstances.php
with
22 additions
and
3 deletions
src/EventCreationService.php
+
10
−
1
View file @
61067b35
...
...
@@ -533,7 +533,12 @@ class EventCreationService {
$entity
=
$storage
->
create
(
$data
);
}
else
{
// Grab the untranslated event series.
$original
=
$event
->
getUntranslated
();
// Find the corresponding default language event instance that matches
// the date and time of the version we wish to translate, so that we are
// mapping the translations from default language to translated language
// appropriately.
$entity_ids
=
$storage
->
getQuery
()
->
condition
(
'date__value'
,
$data
[
'date'
][
'value'
])
->
condition
(
'date__end_value'
,
$data
[
'date'
][
'end_value'
])
...
...
@@ -544,8 +549,12 @@ class EventCreationService {
->
execute
();
if
(
!
empty
(
$entity_ids
))
{
// Load the default language version of the event instance.
$entity
=
$storage
->
load
(
reset
(
$entity_ids
));
$entity
->
addTranslation
(
$event
->
language
()
->
getId
(),
$data
);
// Only add a translation if we do not already have one.
if
(
!
$entity
->
hasTranslation
(
$event
->
language
()
->
getId
()))
{
$entity
->
addTranslation
(
$event
->
language
()
->
getId
(),
$data
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/EventUserTrait.php
+
11
−
0
View file @
61067b35
...
...
@@ -80,4 +80,15 @@ trait EventUserTrait {
public
static
function
getDefaultEntityOwner
()
{
return
\Drupal
::
currentUser
()
->
id
();
}
/**
* Backwards compatibility for getCurrentUserId().
*
* @return mixed
* A default value for the uid field.
*/
public
static
function
getCurrentUserId
()
{
return
static
::
getDefaultEntityOwner
();
}
}
This diff is collapsed.
Click to expand it.
src/Plugin/ComputedField/EventInstances.php
+
1
−
2
View file @
61067b35
...
...
@@ -20,7 +20,6 @@ class EventInstances extends EntityReferenceFieldItemList {
if
(
!
empty
(
$entity
->
id
()))
{
$instances
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'eventinstance'
)
->
loadByProperties
([
'eventseries_id'
=>
$entity
->
id
(),
'langcode'
=>
$this
->
getLangcode
(),
]);
// Sort by instance start date and reindex by field item delta, as
...
...
@@ -30,7 +29,7 @@ class EventInstances extends EntityReferenceFieldItemList {
});
foreach
(
$instances
as
$key
=>
$instance
)
{
$this
->
list
[
$key
]
=
$this
->
createItem
(
$key
,
$instance
);
$this
->
list
[
$key
]
=
$this
->
createItem
(
$key
,
$instance
->
getTranslation
(
$this
->
getLangcode
())
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment