66
77use ApiSkeletons \Doctrine \GraphQL \AbstractContainer ;
88use ApiSkeletons \Doctrine \GraphQL \Hydrator \Filter \Password ;
9- use ApiSkeletons \Doctrine \GraphQL \Hydrator \Strategy \AssociationDefault ;
10- use ApiSkeletons \Doctrine \GraphQL \Hydrator \Strategy \FieldDefault ;
11- use ApiSkeletons \Doctrine \GraphQL \Hydrator \Strategy \NullifyOwningAssociation ;
12- use ApiSkeletons \Doctrine \GraphQL \Hydrator \Strategy \ToBoolean ;
13- use ApiSkeletons \Doctrine \GraphQL \Hydrator \Strategy \ToFloat ;
14- use ApiSkeletons \Doctrine \GraphQL \Hydrator \Strategy \ToInteger ;
15- use ApiSkeletons \Doctrine \GraphQL \Metadata \Metadata ;
9+ use ApiSkeletons \Doctrine \GraphQL \Type \Entity ;
10+ use ApiSkeletons \Doctrine \GraphQL \Type \TypeManager ;
1611use Doctrine \Laminas \Hydrator \DoctrineObject ;
1712use Doctrine \ORM \EntityManager ;
1813use GraphQL \Error \Error ;
19- use Laminas \Hydrator \Filter \FilterComposite ;
20- use Laminas \Hydrator \Filter \FilterEnabledInterface ;
21- use Laminas \Hydrator \Filter \FilterInterface ;
14+ use Laminas \Hydrator \Filter ;
2215use Laminas \Hydrator \NamingStrategy \NamingStrategyEnabledInterface ;
2316use Laminas \Hydrator \NamingStrategy \NamingStrategyInterface ;
2417use Laminas \Hydrator \Strategy \StrategyEnabledInterface ;
3427 */
3528class HydratorFactory extends AbstractContainer
3629{
37- public function __construct (protected EntityManager $ entityManager , protected Metadata $ metadata )
30+ public function __construct (protected EntityManager $ entityManager , protected TypeManager $ typeManager )
3831 {
3932 // Register project defaults
4033 $ this
41- ->set (AssociationDefault::class, new AssociationDefault ())
42- ->set (FieldDefault::class, new FieldDefault ())
43- ->set (NullifyOwningAssociation::class, new NullifyOwningAssociation ())
44- ->set (ToBoolean::class, new ToBoolean ())
45- ->set (ToFloat::class, new ToFloat ())
46- ->set (ToInteger::class, new ToInteger ())
34+ ->set (Strategy \ AssociationDefault::class, new Strategy \ AssociationDefault ())
35+ ->set (Strategy \ FieldDefault::class, new Strategy \ FieldDefault ())
36+ ->set (Strategy \ NullifyOwningAssociation::class, new Strategy \ NullifyOwningAssociation ())
37+ ->set (Strategy \ ToBoolean::class, new Strategy \ ToBoolean ())
38+ ->set (Strategy \ ToFloat::class, new Strategy \ ToFloat ())
39+ ->set (Strategy \ ToInteger::class, new Strategy \ ToInteger ())
4740 ->set (Password::class, new Password ());
4841 }
4942
@@ -55,8 +48,8 @@ public function get(string $id): mixed
5548 return parent ::get ($ id );
5649 }
5750
58- $ entity = $ this ->metadata -> get ( $ id );
59- $ config = $ entity ->getMetadataConfig ();
51+ $ entity = $ this ->typeManager -> build (Entity::class, $ id );
52+ $ config = $ entity ->getMetadata ();
6053 $ hydrator = new DoctrineObject ($ this ->entityManager , $ config ['byValue ' ]);
6154
6255 // Create field strategy and assign to hydrator
@@ -72,13 +65,13 @@ public function get(string $id): mixed
7265 }
7366
7467 // Create filters and assign to hydrator
75- if ($ hydrator instanceof FilterEnabledInterface) {
68+ if ($ hydrator instanceof Filter \ FilterEnabledInterface) {
7669 foreach ($ config ['filters ' ] as $ name => $ filterConfig ) {
7770 // Default filters to AND
78- $ condition = $ filterConfig ['condition ' ] ?? FilterComposite::CONDITION_AND ;
71+ $ condition = $ filterConfig ['condition ' ] ?? Filter \ FilterComposite::CONDITION_AND ;
7972 $ filterClass = $ filterConfig ['filter ' ];
8073 assert (
81- in_array (FilterInterface::class, class_implements ($ filterClass )),
74+ in_array (Filter \ FilterInterface::class, class_implements ($ filterClass )),
8275 'Filter must implement ' . StrategyInterface::class,
8376 );
8477
0 commit comments