1414namespace ApiPlatform \Doctrine \Orm \State ;
1515
1616use ApiPlatform \Doctrine \Common \State \LinksHandlerLocatorTrait ;
17- use ApiPlatform \Doctrine \Common \State \ModelTransformerLocatorTrait ;
17+ use ApiPlatform \Doctrine \Common \State \ResourceTransformerLocatorTrait ;
1818use ApiPlatform \Doctrine \Orm \Extension \QueryCollectionExtensionInterface ;
1919use ApiPlatform \Doctrine \Orm \Extension \QueryResultCollectionExtensionInterface ;
2020use ApiPlatform \Doctrine \Orm \Util \QueryNameGenerator ;
@@ -37,17 +37,21 @@ final class CollectionProvider implements ProviderInterface
3737{
3838 use LinksHandlerLocatorTrait;
3939 use LinksHandlerTrait;
40- use ModelTransformerLocatorTrait ;
40+ use ResourceTransformerLocatorTrait ;
4141 use StateOptionsTrait;
4242
4343 /**
4444 * @param QueryCollectionExtensionInterface[] $collectionExtensions
4545 */
46- public function __construct (ResourceMetadataCollectionFactoryInterface $ resourceMetadataCollectionFactory , ManagerRegistry $ managerRegistry , private readonly iterable $ collectionExtensions = [], ?ContainerInterface $ handleLinksLocator = null )
46+ public function __construct (ResourceMetadataCollectionFactoryInterface $ resourceMetadataCollectionFactory ,
47+ ManagerRegistry $ managerRegistry ,
48+ private readonly iterable $ collectionExtensions = [],
49+ ?ContainerInterface $ handleLinksLocator = null ,
50+ ?ContainerInterface $ resourceTransformerLocator = null )
4751 {
4852 $ this ->resourceMetadataCollectionFactory = $ resourceMetadataCollectionFactory ;
4953 $ this ->handleLinksLocator = $ handleLinksLocator ;
50- $ this ->transformEntityLocator = $ handleLinksLocator ;
54+ $ this ->resourceTransformerLocator = $ resourceTransformerLocator ;
5155 $ this ->managerRegistry = $ managerRegistry ;
5256 }
5357
@@ -83,7 +87,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
8387
8488 $ result = $ result ?? $ queryBuilder ->getQuery ()->getResult ();
8589
86- return match ($ transformer = $ this ->getEntityTransformer ($ operation )) {
90+ return match ($ transformer = $ this ->getToResourceTransformer ($ operation )) {
8791 null => $ result ,
8892 default => array_map ($ transformer , iterator_to_array ($ result )),
8993 };
0 commit comments