From d972fcdfbdef08730b26fa3f2194a852e4398586 Mon Sep 17 00:00:00 2001 From: "alexander.heidrich" Date: Wed, 18 Jan 2023 16:51:32 +0100 Subject: [PATCH] bugfix: show Assets as field types --- .../CreateERDiagramXMLExportCommand.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ERDiagramXMLExportBundle/Command/CreateERDiagramXMLExportCommand.php b/ERDiagramXMLExportBundle/Command/CreateERDiagramXMLExportCommand.php index 960b6fe..fa3af2d 100644 --- a/ERDiagramXMLExportBundle/Command/CreateERDiagramXMLExportCommand.php +++ b/ERDiagramXMLExportBundle/Command/CreateERDiagramXMLExportCommand.php @@ -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) : '']; }