From a7c94e3b002a08e17fae0659ab81c62a6104a7cf Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:54:24 +0100 Subject: [PATCH] TASK: Fix `PromotedElementsCreationHandler` to work with new references api --- .../PromotedElementsCreationHandlerFactory.php | 8 +++----- Tests/Unit/CreationDialogNodeTypePostprocessorTest.php | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php b/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php index 64993e8359..5dababedaa 100644 --- a/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php +++ b/Classes/Infrastructure/ContentRepository/CreationDialog/PromotedElementsCreationHandlerFactory.php @@ -40,8 +40,7 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele $setReferencesCommands = []; foreach ($elements as $elementName => $elementValue) { // handle properties - // todo this will be simplified once hasProperty does not return true for references - if ($nodeType->hasProperty($elementName) && ($nodeType->getPropertyType($elementName) !== 'references' && $nodeType->getPropertyType($elementName) !== 'reference')) { + if ($nodeType->hasProperty($elementName)) { $propertyConfiguration = $nodeType->getProperties()[$elementName]; if ( ($propertyConfiguration['ui']['showInCreationDialog'] ?? false) === true @@ -52,10 +51,9 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele } // handle references - // todo this will be replaced by $nodeType->hasReference() - if ($nodeType->hasProperty($elementName) && ($nodeType->getPropertyType($elementName) === 'references' || $nodeType->getPropertyType($elementName) === 'reference')) { + if ($nodeType->hasReference($elementName)) { assert($elementValue instanceof NodeAggregateIds); - $referenceConfiguration = $nodeType->getProperties()[$elementName]; + $referenceConfiguration = $nodeType->getReferences()[$elementName]; if ( ($referenceConfiguration['ui']['showInCreationDialog'] ?? false) === true ) { diff --git a/Tests/Unit/CreationDialogNodeTypePostprocessorTest.php b/Tests/Unit/CreationDialogNodeTypePostprocessorTest.php index 38bf059b00..8228b78b38 100644 --- a/Tests/Unit/CreationDialogNodeTypePostprocessorTest.php +++ b/Tests/Unit/CreationDialogNodeTypePostprocessorTest.php @@ -33,6 +33,7 @@ public function setUp(): void public function processCopiesInspectorConfigurationToCreationDialogElements(): void { $configuration = [ + 'references' => [], 'properties' => [ 'somePropertyName' => [ 'ui' => [ @@ -215,6 +216,8 @@ public function processRespectsEditorDefaultConfiguration(): void public function processConvertsCreationDialogConfiguration(): void { $configuration = [ + 'references' => [], + 'properties' => [], 'ui' => [ 'creationDialog' => [ 'elements' => [ @@ -307,6 +310,8 @@ public function processConvertsCreationDialogConfiguration(): void ]); $expectedResult = [ + 'references' => [], + 'properties' => [], 'ui' => [ 'creationDialog' => [ 'elements' => [ @@ -403,6 +408,8 @@ public function processConvertsCreationDialogConfiguration(): void public function processDoesNotThrowExceptionIfNoCreationDialogEditorCanBeResolved(): void { $configuration = [ + 'references' => [], + 'properties' => [], 'ui' => [ 'creationDialog' => [ 'elements' => [