44
55namespace RZ \Roadiz \Typescript \Declaration ;
66
7+ use RZ \Roadiz \Contracts \NodeType \NodeTypeClassLocatorInterface ;
78use RZ \Roadiz \Contracts \NodeType \NodeTypeFieldInterface ;
89use RZ \Roadiz \Contracts \NodeType \NodeTypeInterface ;
910use RZ \Roadiz \Typescript \Declaration \Generators \AbstractFieldGenerator ;
1718
1819final readonly class DeclarationGeneratorFactory
1920{
20- public function __construct (private ParameterBag $ nodeTypesBag )
21- {
21+ public function __construct (
22+ private ParameterBag $ nodeTypesBag ,
23+ private NodeTypeClassLocatorInterface $ nodeTypeClassLocator ,
24+ ) {
2225 }
2326
2427 public function getNodeTypesBag (): ParameterBag
@@ -35,15 +38,16 @@ public function createForNodeType(NodeTypeInterface $nodeType): NodeTypeGenerato
3538 {
3639 return new NodeTypeGenerator (
3740 $ nodeType ,
38- $ this
41+ $ this ,
42+ $ this ->nodeTypeClassLocator
3943 );
4044 }
4145
4246 public function createForNodeTypeField (NodeTypeFieldInterface $ field ): AbstractFieldGenerator
4347 {
4448 return match (true ) {
4549 $ field ->isDocuments () => new DocumentsFieldGenerator ($ field , $ this ->nodeTypesBag ),
46- $ field ->isNodes () => new NodeReferencesFieldGenerator ($ field , $ this ->nodeTypesBag ),
50+ $ field ->isNodes () => new NodeReferencesFieldGenerator ($ this -> nodeTypeClassLocator , $ field , $ this ->nodeTypesBag ),
4751 $ field ->isChildrenNodes () => new ChildrenNodeFieldGenerator ($ field , $ this ->nodeTypesBag ),
4852 $ field ->isMultiple (), $ field ->isEnum () => new EnumFieldGenerator ($ field , $ this ->nodeTypesBag ),
4953 default => new ScalarFieldGenerator ($ field , $ this ->nodeTypesBag ),
0 commit comments