Skip to content
Snippets Groups Projects
Commit 8b5b5480 authored by Mikael Meulle's avatar Mikael Meulle
Browse files

Issue #3474137 by just_like_good_vibes: Check FieldPropertySource::transTypeProp

parent b1938c29
No related branches found
No related tags found
1 merge request!212Corrected transTyping
Pipeline #282713 passed with warnings
......@@ -36,7 +36,11 @@ class FieldPropertySource extends FieldValueSourceBase {
return NULL;
}
$property_value = $this->extractPropertyValue($field_item_at_delta, $property, $lang_code);
$prop_typ_types = (isset($this->propDefinition['type']) && is_array($this->propDefinition['type'])) ? $this->propDefinition['type'] : [];
$prop_typ_types = [];
if (isset($this->propDefinition['type'])) {
// Type can be an array of types or a single type.
$prop_typ_types = is_array($this->propDefinition['type']) ? $this->propDefinition['type'] : [$this->propDefinition['type']];
}
return $this->transTypeProp($property_value, $prop_typ_types);
}
......@@ -56,8 +60,8 @@ class FieldPropertySource extends FieldValueSourceBase {
private function transTypeProp(mixed $value, array $prop_types): mixed {
foreach ($prop_types as $prop_type) {
$converted = match ($prop_type) {
'decimal', 'integer', 'duration' => is_int($value) ? $value : (int) $value,
'float' => is_float($value) ? $value : (float) $value,
'integer' => is_int($value) ? $value : (int) $value,
'float', 'decimal' => is_float($value) ? $value : (float) $value,
'boolean' => is_bool($value) ? $value : (boolean) $value,
default => NULL,
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment