6
6
7
7
use Neos \ContentRepository \Core \Factory \ContentRepositoryServiceFactoryDependencies ;
8
8
use Neos \ContentRepository \Core \Factory \ContentRepositoryServiceFactoryInterface ;
9
+ use Neos \ContentRepository \Core \Feature \NodeReferencing \Command \SetNodeReferences ;
10
+ use Neos \ContentRepository \Core \Feature \NodeReferencing \Dto \NodeReferencesToWrite ;
9
11
use Neos \ContentRepository \Core \NodeType \NodeTypeManager ;
12
+ use Neos \ContentRepository \Core \SharedModel \Node \ReferenceName ;
10
13
use Neos \Neos \Ui \Domain \NodeCreation \NodeCreationCommands ;
11
14
use Neos \Neos \Ui \Domain \NodeCreation \NodeCreationElements ;
12
15
use Neos \Neos \Ui \Domain \NodeCreation \NodeCreationHandlerInterface ;
@@ -31,8 +34,10 @@ public function __construct(
31
34
public function handle (NodeCreationCommands $ commands , NodeCreationElements $ elements ): NodeCreationCommands
32
35
{
33
36
$ nodeType = $ this ->nodeTypeManager ->getNodeType ($ commands ->first ->nodeTypeName );
37
+
38
+ // handle properties
34
39
$ propertyValues = $ commands ->first ->initialPropertyValues ;
35
- foreach ($ nodeType ->getConfiguration ( ' properties ' ) as $ propertyName => $ propertyConfiguration ) {
40
+ foreach ($ nodeType ->getProperties ( ) as $ propertyName => $ propertyConfiguration ) {
36
41
if (
37
42
!isset ($ propertyConfiguration ['ui ' ]['showInCreationDialog ' ])
38
43
|| $ propertyConfiguration ['ui ' ]['showInCreationDialog ' ] !== true
@@ -43,11 +48,39 @@ public function handle(NodeCreationCommands $commands, NodeCreationElements $ele
43
48
if (!$ elements ->hasPropertyLike ($ propertyName )) {
44
49
continue ;
45
50
}
46
- // todo support also references https://github.com/neos/neos-ui/issues/3615
47
51
$ propertyValues = $ propertyValues ->withValue ($ propertyName , $ elements ->getPropertyLike ($ propertyName ));
48
52
}
49
53
50
- return $ commands ->withInitialPropertyValues ($ propertyValues );
54
+ // handle references
55
+ $ setReferencesCommands = [];
56
+ foreach ($ nodeType ->getProperties () as $ referenceName => $ referenceConfiguration ) {
57
+ // todo this will be replaced by $nodeType->getReferences()
58
+ if ($ nodeType ->getPropertyType ($ referenceName ) !== 'references ' && $ nodeType ->getPropertyType ($ referenceName ) !== 'reference ' ) {
59
+ continue ; // no a reference
60
+ }
61
+ if (
62
+ !isset ($ referenceConfiguration ['ui ' ]['showInCreationDialog ' ])
63
+ || $ referenceConfiguration ['ui ' ]['showInCreationDialog ' ] !== true
64
+ ) {
65
+ // not a promoted reference
66
+ continue ;
67
+ }
68
+ if (!$ elements ->hasReferenceLike ($ referenceName )) {
69
+ continue ;
70
+ }
71
+
72
+ $ setReferencesCommands [] = SetNodeReferences::create (
73
+ $ commands ->first ->contentStreamId ,
74
+ $ commands ->first ->nodeAggregateId ,
75
+ $ commands ->first ->originDimensionSpacePoint ,
76
+ ReferenceName::fromString ($ referenceName ),
77
+ NodeReferencesToWrite::fromNodeAggregateIds ($ elements ->getReferenceLike ($ referenceName ))
78
+ );
79
+ }
80
+
81
+ return $ commands
82
+ ->withInitialPropertyValues ($ propertyValues )
83
+ ->withAdditionalCommands (...$ setReferencesCommands );
51
84
}
52
85
};
53
86
}
0 commit comments