Merge pull request #1248 from bolt/collections-and-sets-in-api

Collections and Sets in API
This commit is contained in:
Bob den Otter
2020-03-30 20:54:17 +02:00
committed by GitHub
2 changed files with 27 additions and 0 deletions

View File

@@ -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();

View File

@@ -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;
}
}