mirror of
https://github.com/jbcr/core.git
synced 2026-03-30 21:02:07 +02:00
Merge pull request #1248 from bolt/collections-and-sets-in-api
Collections and Sets in API
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user