From 8b5b54800d028da2cb72239b6e737c545018e411 Mon Sep 17 00:00:00 2001 From: Mikael Meulle <21535-just_like_good_vibes@users.noreply.drupalcode.org> Date: Fri, 13 Sep 2024 20:06:27 +0000 Subject: [PATCH] Issue #3474137 by just_like_good_vibes: Check FieldPropertySource::transTypeProp --- src/Plugin/UiPatterns/Source/FieldPropertySource.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Plugin/UiPatterns/Source/FieldPropertySource.php b/src/Plugin/UiPatterns/Source/FieldPropertySource.php index d68a9227b..fa5e9eb93 100644 --- a/src/Plugin/UiPatterns/Source/FieldPropertySource.php +++ b/src/Plugin/UiPatterns/Source/FieldPropertySource.php @@ -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, }; -- GitLab