Skip to content
Snippets Groups Projects
Commit ebce418b authored by mxh's avatar mxh
Browse files

Issue #3299753 by mxh: Add more data types as parameter plugins

parent 8556d854
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment