Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parameters-3486691
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
parameters-3486691
Commits
ebce418b
Commit
ebce418b
authored
2 years ago
by
mxh
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3299753
by mxh: Add more data types as parameter plugins
parent
8556d854
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Parameter/Content.php
+16
-6
16 additions, 6 deletions
src/Plugin/Parameter/Content.php
with
16 additions
and
6 deletions
src/Plugin/Parameter/Content.php
+
16
−
6
View file @
ebce418b
...
...
@@ -186,16 +186,26 @@ class Content extends ParameterBase implements PropertyParameterInterface, Depen
// Save the entity, if not yet available.
if
(
$entity
->
isNew
())
{
if
(
$entity
->
getEntityType
()
->
hasKey
(
'uuid'
))
{
$lock_name
=
'parameters:content:'
.
$entity
->
uuid
();
}
else
{
$lock_name
=
'parameters:content:'
.
$entity
->
id
()
??
uniqid
();
}
$lock_name
=
$entity
->
getEntityType
()
->
hasKey
(
'uuid'
)
?
'parameters:content:'
.
$entity
->
uuid
()
:
'parameters:content:'
.
(
$entity
->
id
()
??
uniqid
());
if
(
\Drupal
::
lock
()
->
acquire
(
$lock_name
))
{
$entity
->
save
();
\Drupal
::
lock
()
->
release
(
$lock_name
);
}
elseif
(
$entity
->
uuid
())
{
// Someone else is already saving it. Wait a bit and then try to get it.
$i
=
0
;
$loaded
=
NULL
;
while
(
!
(
$loaded
=
$this
->
entityRepository
->
loadEntityByUuid
(
$entity
->
getEntityTypeId
(),
$entity
->
uuid
())))
{
$i
++
;
usleep
(
10000
);
if
(
$i
>
1000
)
{
// More than 10 seconds have elapsed without any luck, abort.
\Drupal
::
logger
(
'parameters'
)
->
error
(
sprintf
(
"Failed to load an entity from repository. Type: %s, UUID: %s"
,
$entity
->
getEntityTypeId
(),
$entity
->
uuid
()));
break
;
}
}
$entity
=
$loaded
??
$entity
;
}
}
return
$entity
;
...
...
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