4646use ApiPlatform \GraphQl \Type \TypesFactory ;
4747use ApiPlatform \GraphQl \Type \TypesFactoryInterface ;
4848use ApiPlatform \Hydra \JsonSchema \SchemaFactory as HydraSchemaFactory ;
49+ use ApiPlatform \Hydra \Serializer \CollectionFiltersNormalizer as HydraFiltersCollectionNormalizer ;
4950use ApiPlatform \Hydra \Serializer \CollectionNormalizer as HydraCollectionNormalizer ;
5051use ApiPlatform \Hydra \Serializer \DocumentationNormalizer as HydraDocumentationNormalizer ;
5152use ApiPlatform \Hydra \Serializer \EntrypointNormalizer as HydraEntrypointNormalizer ;
7374use ApiPlatform \Laravel \Controller \ApiPlatformController ;
7475use ApiPlatform \Laravel \Eloquent \Extension \FilterQueryExtension ;
7576use ApiPlatform \Laravel \Eloquent \Extension \QueryExtensionInterface ;
77+ use ApiPlatform \Laravel \Eloquent \Filter \DateFilter ;
78+ use ApiPlatform \Laravel \Eloquent \Filter \EqualsFilter ;
7679use ApiPlatform \Laravel \Eloquent \Filter \FilterInterface as EloquentFilterInterface ;
77- use ApiPlatform \Laravel \Eloquent \Filter \SearchFilter ;
80+ use ApiPlatform \Laravel \Eloquent \Filter \OrderFilter ;
81+ use ApiPlatform \Laravel \Eloquent \Filter \PartialSearchFilter ;
7882use ApiPlatform \Laravel \Eloquent \Metadata \Factory \Property \EloquentAttributePropertyMetadataFactory ;
7983use ApiPlatform \Laravel \Eloquent \Metadata \Factory \Property \EloquentPropertyMetadataFactory ;
8084use ApiPlatform \Laravel \Eloquent \Metadata \Factory \Property \EloquentPropertyNameCollectionMetadataFactory ;
106110use ApiPlatform \Laravel \State \SwaggerUiProvider ;
107111use ApiPlatform \Laravel \State \ValidateProvider ;
108112use ApiPlatform \Metadata \Exception \NotExposedHttpException ;
109- use ApiPlatform \Metadata \FilterInterface ;
110113use ApiPlatform \Metadata \IdentifiersExtractor ;
111114use ApiPlatform \Metadata \IdentifiersExtractorInterface ;
112115use ApiPlatform \Metadata \InflectorInterface ;
195198use Symfony \Component \Serializer \Mapping \Factory \ClassMetadataFactoryInterface ;
196199use Symfony \Component \Serializer \Mapping \Loader \AttributeLoader ;
197200use Symfony \Component \Serializer \Mapping \Loader \LoaderInterface ;
201+ use Symfony \Component \Serializer \NameConverter \CamelCaseToSnakeCaseNameConverter ;
198202use Symfony \Component \Serializer \NameConverter \MetadataAwareNameConverter ;
199203use Symfony \Component \Serializer \NameConverter \NameConverterInterface ;
200204use Symfony \Component \Serializer \Normalizer \ArrayDenormalizer ;
@@ -322,6 +326,7 @@ public function register(): void
322326 new EloquentResourceCollectionMetadataFactory (
323327 new ParameterResourceMetadataCollectionFactory (
324328 $ this ->app ->make (PropertyNameCollectionFactoryInterface::class),
329+ $ this ->app ->make (PropertyMetadataFactoryInterface::class),
325330 new AlternateUriResourceMetadataCollectionFactory (
326331 new FiltersResourceMetadataCollectionFactory (
327332 new FormatsResourceMetadataCollectionFactory (
@@ -335,8 +340,8 @@ public function register(): void
335340 $ app ->make (PathSegmentNameGeneratorInterface::class),
336341 new NotExposedOperationResourceMetadataCollectionFactory (
337342 $ app ->make (LinkFactoryInterface::class),
338- new ConcernsResourceMetadataCollectionFactory (
339- new AttributesResourceMetadataCollectionFactory (
343+ new AttributesResourceMetadataCollectionFactory (
344+ new ConcernsResourceMetadataCollectionFactory (
340345 null ,
341346 $ app ->make (LoggerInterface::class),
342347 [
@@ -349,7 +354,7 @@ public function register(): void
349354 'routePrefix ' => $ config ->get ('api-platform.routes.prefix ' ) ?? '/ ' ,
350355 ],
351356 $ config ->get ('api-platform.graphql.enabled ' ),
352- )
357+ ),
353358 )
354359 )
355360 )
@@ -361,7 +366,8 @@ public function register(): void
361366 )
362367 )
363368 ),
364- $ app ->make (FilterInterface::class)
369+ $ app ->make ('filters ' ),
370+ $ app ->make (CamelCaseToSnakeCaseNameConverter::class)
365371 )
366372 ),
367373 true === $ config ->get ('app.debug ' ) ? 'array ' : 'file '
@@ -378,13 +384,7 @@ public function register(): void
378384
379385 $ this ->app ->bind (OperationMetadataFactoryInterface::class, OperationMetadataFactory::class);
380386
381- $ this ->app ->tag ([SearchFilter::class], EloquentFilterInterface::class);
382- $ this ->app ->tag ([SearchFilter::class, PropertyFilter::class], FilterInterface::class);
383- $ this ->app ->singleton (FilterInterface::class, function (Application $ app ) {
384- $ tagged = iterator_to_array ($ app ->tagged (FilterInterface::class));
385-
386- return new ServiceLocator ($ tagged );
387- });
387+ $ this ->app ->tag ([EqualsFilter::class, PartialSearchFilter::class, DateFilter::class, OrderFilter::class], EloquentFilterInterface::class);
388388
389389 $ this ->app ->bind (FilterQueryExtension::class, function (Application $ app ) {
390390 $ tagged = iterator_to_array ($ app ->tagged (EloquentFilterInterface::class));
@@ -445,6 +445,13 @@ public function register(): void
445445
446446 $ this ->app ->tag ([SerializerFilterParameterProvider::class], ParameterProviderInterface::class);
447447
448+ $ this ->app ->singleton ('filters ' , function (Application $ app ) {
449+ return new ServiceLocator (array_merge (
450+ iterator_to_array ($ app ->tagged (SerializerFilterInterface::class)),
451+ iterator_to_array ($ app ->tagged (EloquentFilterInterface::class))
452+ ));
453+ });
454+
448455 $ this ->app ->singleton (ParameterProvider::class, function (Application $ app ) {
449456 $ tagged = iterator_to_array ($ app ->tagged (ParameterProviderInterface::class));
450457
@@ -673,7 +680,7 @@ public function register(): void
673680 $ app ->make (PropertyNameCollectionFactoryInterface::class),
674681 $ app ->make (PropertyMetadataFactoryInterface::class),
675682 $ app ->make (SchemaFactoryInterface::class),
676- $ app -> make (FilterInterface::class) ,
683+ null ,
677684 $ config ->get ('api-platform.formats ' ),
678685 null , // ?Options $openApiOptions = null,
679686 $ app ->make (PaginationOptions::class), // ?PaginationOptions $paginationOptions = null,
@@ -737,12 +744,16 @@ public function register(): void
737744
738745 $ this ->app ->singleton (HydraPartialCollectionViewNormalizer::class, function (Application $ app ) use ($ defaultContext ) {
739746 return new HydraPartialCollectionViewNormalizer (
740- new HydraCollectionNormalizer (
741- $ app ->make (ContextBuilderInterface::class),
742- $ app ->make (ResourceClassResolverInterface::class),
743- $ app ->make (IriConverterInterface::class),
747+ new HydraFiltersCollectionNormalizer (
748+ new HydraCollectionNormalizer (
749+ $ app ->make (ContextBuilderInterface::class),
750+ $ app ->make (ResourceClassResolverInterface::class),
751+ $ app ->make (IriConverterInterface::class),
752+ $ app ->make (ResourceMetadataCollectionFactoryInterface::class),
753+ $ defaultContext
754+ ),
744755 $ app ->make (ResourceMetadataCollectionFactoryInterface::class),
745- $ defaultContext
756+ $ app -> make (ResourceClassResolverInterface::class),
746757 ),
747758 'page ' ,
748759 'pagination ' ,
0 commit comments