fix: [workflow:formatConvert] Make sure to include the __allTags when in converting from event scope

pull/9044/head
Sami Mokaddem 2023-04-19 16:19:41 +02:00
parent d8f5000871
commit 077b2e1c06
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 34 additions and 0 deletions

View File

@ -44,6 +44,13 @@ class WorkflowFormatConverterTool
{
$converted = [];
$converted = JSONConverterTool::convert($event, false, true);
$eventTags = $converted['Event']['Tag'];
foreach ($converted['Event']['Attribute'] as $i => $attribute) {
$converted['Event']['Attribute'][$i] = self::__propagateTagToAttributes($attribute, $eventTags);
}
foreach ($converted['Event']['Object'] as $i => $object) {
$converted['Event']['Object'][$i] = self::__propagateTagToObjectAttributes($object, $eventTags);
}
return $converted;
}
@ -101,6 +108,33 @@ class WorkflowFormatConverterTool
return $converted;
}
private static function __propagateTagToAttributes(array $attribute, array $eventTags): array
{
$allTags = [];
if (!empty($eventTags)) {
foreach ($eventTags as $eventTag) {
$eventTag['inherited'] = true;
$allTags[] = $eventTag;
}
}
if (!empty($attribute['Tag'])) {
foreach ($attribute['Tag'] as $tag) {
$tag['inherited'] = false;
$allTags[] = $tag;
}
}
$attribute['_allTags'] = $allTags;
return $attribute;
}
private static function __propagateTagToObjectAttributes(array $object, array $eventTags): array
{
foreach ($object['Attribute'] as $i => $attribute) {
$object['Attribute'][$i] = self::__propagateTagToAttributes($attribute, $eventTags);
}
return $object;
}
private static function __encapsulateEntityWithEvent(array $data): array
{
$eventModel = ClassRegistry::init('Event');