diff --git a/core/kernel/persistence/starsql/class.Resource.php b/core/kernel/persistence/starsql/class.Resource.php index 7ef95ca4b..8495c9117 100644 --- a/core/kernel/persistence/starsql/class.Resource.php +++ b/core/kernel/persistence/starsql/class.Resource.php @@ -543,22 +543,28 @@ public function getPropertiesValues(core_kernel_classes_Resource $resource, $pro foreach ($result->get('resource')->getProperties() as $key => $value) { if (in_array($key, $propertyUris)) { if (is_iterable($value)) { - $returnValue[$key] = array_merge( - $returnValue[$key] ?? [], - $this->getLanguageProcessor()->filterByLanguage($value, [$dataLanguage, $defaultLanguage]) - ); + $returnValue[$key] = + array_map( + fn($value) => $this->formatValue($value), + array_merge( + $returnValue[$key] ?? [], + $this->getLanguageProcessor()->filterByLanguage( + $value, + [$dataLanguage, $defaultLanguage] + ) + ) + ); } else { - $returnValue[$key][] = common_Utils::isUri($value) - ? $this->getModel()->getResource($value) - : new core_kernel_classes_Literal($this->getLanguageProcessor()->parseTranslatedValue($value)); + $returnValue[$key][] = $this->formatValue( + $value, + [$this->getLanguageProcessor(), 'parseTranslatedValue'] + ); } } } foreach ($result->get('relationships') as $relationship) { if (in_array($relationship['relationship'], $propertyUris)) { - $returnValue[$relationship['relationship']][] = common_Utils::isUri($relationship['relatedResourceUri']) - ? $this->getModel()->getResource($relationship['relatedResourceUri']) - : new core_kernel_classes_Literal($relationship['relatedResourceUri']); + $returnValue[$relationship['relationship']][] = $this->formatValue($relationship['relatedResourceUri']); } } @@ -639,4 +645,15 @@ private function buildTriplesFromNode(core_kernel_classes_ContainerCollection $t return $tripleCollection; } + + private function formatValue($value, array $literalValueProcessingCallback = []) + { + return common_Utils::isUri($value) ? + $this->getModel()->getResource($value) + : new core_kernel_classes_Literal( + !empty($literalValueProcessingCallback) + ? call_user_func($literalValueProcessingCallback, $value) + : $value + ); + } }