diff --git a/src/Entity/Field/CollectionField.php b/src/Entity/Field/CollectionField.php index 89db446f..c2d7488e 100644 --- a/src/Entity/Field/CollectionField.php +++ b/src/Entity/Field/CollectionField.php @@ -66,6 +66,22 @@ class CollectionField extends Field implements FieldInterface, FieldParentInterf return $fields->toArray(); } + public function getApiValue() + { + $fields = $this->getValue(); + $result = []; + + foreach ($fields as $field) { + $result[] = [ + 'name' => $field->getName(), + 'type' => $field->getType(), + 'value' => $field->getApiValue(), + ]; + } + + return $result; + } + public function getDefaultValue() { $default = parent::getDefaultValue(); diff --git a/src/Entity/Field/SetField.php b/src/Entity/Field/SetField.php index df62beb6..919d39ba 100644 --- a/src/Entity/Field/SetField.php +++ b/src/Entity/Field/SetField.php @@ -45,4 +45,15 @@ class SetField extends Field implements FieldInterface, FieldParentInterface return $result; } + + public function getApiValue() + { + $result = []; + + foreach ($this->getValue() as $key => $value) { + $result[$key] = $value->getApiValue(); + } + + return $result; + } }