66
77use ApiSkeletons \Doctrine \ORM \GraphQL \Attribute ;
88use ApiSkeletons \Doctrine \ORM \GraphQL \Config ;
9- use ApiSkeletons \Doctrine \ORM \GraphQL \Event \Metadata ;
9+ use ApiSkeletons \Doctrine \ORM \GraphQL \Event \Metadata as MetadataEvent ;
1010use ApiSkeletons \Doctrine \ORM \GraphQL \Filter \Filters ;
1111use ApiSkeletons \Doctrine \ORM \GraphQL \Hydrator \Strategy ;
12+ use ApiSkeletons \Doctrine \ORM \GraphQL \Metadata ;
1213use ApiSkeletons \Doctrine \ORM \GraphQL \Metadata \Common \MetadataFactory as CommonMetadataFactory ;
13- use ArrayObject ;
1414use Doctrine \ORM \EntityManager ;
1515use Doctrine \ORM \Mapping \ClassMetadata ;
1616use League \Event \EventDispatcher ;
1717use Override ;
1818use ReflectionClass ;
1919
2020use function assert ;
21- use function count ;
2221
2322/**
2423 * Build metadata for entities
2524 */
2625class MetadataFactory extends CommonMetadataFactory
2726{
2827 public function __construct (
29- protected ArrayObject $ metadata ,
28+ protected Metadata $ metadata ,
3029 protected readonly EntityManager $ entityManager ,
3130 protected readonly Config $ config ,
3231 protected readonly GlobalEnable $ globalEnable ,
@@ -37,9 +36,9 @@ public function __construct(
3736 /**
3837 * Build metadata for all entities and return it
3938 */
40- public function __invoke (): ArrayObject
39+ public function getMetadata (): Metadata
4140 {
42- if (count ( $ this ->metadata )) {
41+ if ($ this ->metadata -> count ( )) {
4342 return $ this ->metadata ;
4443 }
4544
@@ -51,7 +50,7 @@ public function __invoke(): ArrayObject
5150
5251 // If global enable is set, use the GlobalEnable class to build metadata
5352 if ($ this ->config ->getGlobalEnable ()) {
54- $ this ->metadata = ( $ this ->globalEnable ) ($ entityClasses );
53+ $ this ->metadata = $ this ->globalEnable -> getMetadata ($ entityClasses );
5554
5655 return $ this ->metadata ;
5756 }
@@ -71,7 +70,7 @@ public function __invoke(): ArrayObject
7170
7271 // Fire the metadata.build event
7372 $ this ->eventDispatcher ->dispatch (
74- new Metadata ($ this ->metadata , 'metadata.build ' ),
73+ new MetadataEvent ($ this ->metadata , 'metadata.build ' ),
7574 );
7675
7776 return $ this ->metadata ;
0 commit comments