Skip to content

Commit

Permalink
TASK: Fix PromotedElementsCreationHandler to work with new referenc…
Browse files Browse the repository at this point in the history
…es api
  • Loading branch information
mhsdesign committed Mar 18, 2024
1 parent 60b3b10 commit a7c94e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
) {
Expand Down
7 changes: 7 additions & 0 deletions Tests/Unit/CreationDialogNodeTypePostprocessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function setUp(): void
public function processCopiesInspectorConfigurationToCreationDialogElements(): void
{
$configuration = [
'references' => [],
'properties' => [
'somePropertyName' => [
'ui' => [
Expand Down Expand Up @@ -215,6 +216,8 @@ public function processRespectsEditorDefaultConfiguration(): void
public function processConvertsCreationDialogConfiguration(): void
{
$configuration = [
'references' => [],
'properties' => [],
'ui' => [
'creationDialog' => [
'elements' => [
Expand Down Expand Up @@ -307,6 +310,8 @@ public function processConvertsCreationDialogConfiguration(): void
]);

$expectedResult = [
'references' => [],
'properties' => [],
'ui' => [
'creationDialog' => [
'elements' => [
Expand Down Expand Up @@ -403,6 +408,8 @@ public function processConvertsCreationDialogConfiguration(): void
public function processDoesNotThrowExceptionIfNoCreationDialogEditorCanBeResolved(): void
{
$configuration = [
'references' => [],
'properties' => [],
'ui' => [
'creationDialog' => [
'elements' => [
Expand Down

0 comments on commit a7c94e3

Please sign in to comment.