46
46
use ApiPlatform \GraphQl \Type \TypesFactory ;
47
47
use ApiPlatform \GraphQl \Type \TypesFactoryInterface ;
48
48
use ApiPlatform \Hydra \JsonSchema \SchemaFactory as HydraSchemaFactory ;
49
+ use ApiPlatform \Hydra \Serializer \CollectionFiltersNormalizer as HydraFiltersCollectionNormalizer ;
49
50
use ApiPlatform \Hydra \Serializer \CollectionNormalizer as HydraCollectionNormalizer ;
50
51
use ApiPlatform \Hydra \Serializer \DocumentationNormalizer as HydraDocumentationNormalizer ;
51
52
use ApiPlatform \Hydra \Serializer \EntrypointNormalizer as HydraEntrypointNormalizer ;
73
74
use ApiPlatform \Laravel \Controller \ApiPlatformController ;
74
75
use ApiPlatform \Laravel \Eloquent \Extension \FilterQueryExtension ;
75
76
use ApiPlatform \Laravel \Eloquent \Extension \QueryExtensionInterface ;
77
+ use ApiPlatform \Laravel \Eloquent \Filter \DateFilter ;
78
+ use ApiPlatform \Laravel \Eloquent \Filter \EqualsFilter ;
76
79
use 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 ;
78
82
use ApiPlatform \Laravel \Eloquent \Metadata \Factory \Property \EloquentAttributePropertyMetadataFactory ;
79
83
use ApiPlatform \Laravel \Eloquent \Metadata \Factory \Property \EloquentPropertyMetadataFactory ;
80
84
use ApiPlatform \Laravel \Eloquent \Metadata \Factory \Property \EloquentPropertyNameCollectionMetadataFactory ;
106
110
use ApiPlatform \Laravel \State \SwaggerUiProvider ;
107
111
use ApiPlatform \Laravel \State \ValidateProvider ;
108
112
use ApiPlatform \Metadata \Exception \NotExposedHttpException ;
109
- use ApiPlatform \Metadata \FilterInterface ;
110
113
use ApiPlatform \Metadata \IdentifiersExtractor ;
111
114
use ApiPlatform \Metadata \IdentifiersExtractorInterface ;
112
115
use ApiPlatform \Metadata \InflectorInterface ;
195
198
use Symfony \Component \Serializer \Mapping \Factory \ClassMetadataFactoryInterface ;
196
199
use Symfony \Component \Serializer \Mapping \Loader \AttributeLoader ;
197
200
use Symfony \Component \Serializer \Mapping \Loader \LoaderInterface ;
201
+ use Symfony \Component \Serializer \NameConverter \CamelCaseToSnakeCaseNameConverter ;
198
202
use Symfony \Component \Serializer \NameConverter \MetadataAwareNameConverter ;
199
203
use Symfony \Component \Serializer \NameConverter \NameConverterInterface ;
200
204
use Symfony \Component \Serializer \Normalizer \ArrayDenormalizer ;
@@ -322,6 +326,7 @@ public function register(): void
322
326
new EloquentResourceCollectionMetadataFactory (
323
327
new ParameterResourceMetadataCollectionFactory (
324
328
$ this ->app ->make (PropertyNameCollectionFactoryInterface::class),
329
+ $ this ->app ->make (PropertyMetadataFactoryInterface::class),
325
330
new AlternateUriResourceMetadataCollectionFactory (
326
331
new FiltersResourceMetadataCollectionFactory (
327
332
new FormatsResourceMetadataCollectionFactory (
@@ -335,8 +340,8 @@ public function register(): void
335
340
$ app ->make (PathSegmentNameGeneratorInterface::class),
336
341
new NotExposedOperationResourceMetadataCollectionFactory (
337
342
$ app ->make (LinkFactoryInterface::class),
338
- new ConcernsResourceMetadataCollectionFactory (
339
- new AttributesResourceMetadataCollectionFactory (
343
+ new AttributesResourceMetadataCollectionFactory (
344
+ new ConcernsResourceMetadataCollectionFactory (
340
345
null ,
341
346
$ app ->make (LoggerInterface::class),
342
347
[
@@ -349,7 +354,7 @@ public function register(): void
349
354
'routePrefix ' => $ config ->get ('api-platform.routes.prefix ' ) ?? '/ ' ,
350
355
],
351
356
$ config ->get ('api-platform.graphql.enabled ' ),
352
- )
357
+ ),
353
358
)
354
359
)
355
360
)
@@ -361,7 +366,8 @@ public function register(): void
361
366
)
362
367
)
363
368
),
364
- $ app ->make (FilterInterface::class)
369
+ $ app ->make ('filters ' ),
370
+ $ app ->make (CamelCaseToSnakeCaseNameConverter::class)
365
371
)
366
372
),
367
373
true === $ config ->get ('app.debug ' ) ? 'array ' : 'file '
@@ -378,13 +384,7 @@ public function register(): void
378
384
379
385
$ this ->app ->bind (OperationMetadataFactoryInterface::class, OperationMetadataFactory::class);
380
386
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);
388
388
389
389
$ this ->app ->bind (FilterQueryExtension::class, function (Application $ app ) {
390
390
$ tagged = iterator_to_array ($ app ->tagged (EloquentFilterInterface::class));
@@ -445,6 +445,13 @@ public function register(): void
445
445
446
446
$ this ->app ->tag ([SerializerFilterParameterProvider::class], ParameterProviderInterface::class);
447
447
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
+
448
455
$ this ->app ->singleton (ParameterProvider::class, function (Application $ app ) {
449
456
$ tagged = iterator_to_array ($ app ->tagged (ParameterProviderInterface::class));
450
457
@@ -673,7 +680,7 @@ public function register(): void
673
680
$ app ->make (PropertyNameCollectionFactoryInterface::class),
674
681
$ app ->make (PropertyMetadataFactoryInterface::class),
675
682
$ app ->make (SchemaFactoryInterface::class),
676
- $ app -> make (FilterInterface::class) ,
683
+ null ,
677
684
$ config ->get ('api-platform.formats ' ),
678
685
null , // ?Options $openApiOptions = null,
679
686
$ app ->make (PaginationOptions::class), // ?PaginationOptions $paginationOptions = null,
@@ -737,12 +744,16 @@ public function register(): void
737
744
738
745
$ this ->app ->singleton (HydraPartialCollectionViewNormalizer::class, function (Application $ app ) use ($ defaultContext ) {
739
746
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
+ ),
744
755
$ app ->make (ResourceMetadataCollectionFactoryInterface::class),
745
- $ defaultContext
756
+ $ app -> make (ResourceClassResolverInterface::class),
746
757
),
747
758
'page ' ,
748
759
'pagination ' ,
0 commit comments