Skip to content

Commit

Permalink
bugfix: show Assets as field types
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.heidrich committed Jan 18, 2023
1 parent 8b83e1b commit d972fcd
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,20 @@ private function processFieldDefinitions($fieldDefinitions): array
$fields = [$fieldDefinition->getName() => $fieldDefinition->getFieldtype()];

if ($fieldDefinition instanceof AbstractRelations) {
$allowedTypes = array_map(function ($classConfig) use ($fieldDefinition) {
if ($fieldDefinition instanceof ManyToOneRelation) {
return $classConfig['classes'] ?? '';
} else {
return ($classConfig['classes'] . '[]') ?? '';
}
}, $fieldDefinition->getClasses());
$allowedTypes = [];
if ($fieldDefinition->getObjectsAllowed()) {
$allowedTypes = array_map(function ($classConfig) use ($fieldDefinition) {
if ($fieldDefinition instanceof ManyToOneRelation) {
return $classConfig['classes'] ?? '';
} else {
return ($classConfig['classes'] . '[]') ?? '';
}
}, $fieldDefinition->getClasses());
}

if ($fieldDefinition->getAssetsAllowed() || $fieldDefinition->getDocumentsAllowed()) {
$allowedTypes[] = $fieldDefinition instanceof ManyToOneRelation ? 'Asset' : 'Asset[]';
}

$fields = [$fieldDefinition->getName() => !empty($allowedTypes) ? implode(' | ', $allowedTypes) : ''];
}
Expand Down

0 comments on commit d972fcd

Please sign in to comment.