|
49 | 49 | use ApiPlatform\Hal\Serializer\EntrypointNormalizer as HalEntrypointNormalizer;
|
50 | 50 | use ApiPlatform\Hal\Serializer\ItemNormalizer as HalItemNormalizer;
|
51 | 51 | use ApiPlatform\Hal\Serializer\ObjectNormalizer as HalObjectNormalizer;
|
| 52 | +use ApiPlatform\HttpCache\State\AddHeadersProcessor; |
52 | 53 | use ApiPlatform\Hydra\JsonSchema\SchemaFactory as HydraSchemaFactory;
|
53 | 54 | use ApiPlatform\Hydra\Serializer\CollectionFiltersNormalizer as HydraCollectionFiltersNormalizer;
|
54 | 55 | use ApiPlatform\Hydra\Serializer\CollectionNormalizer as HydraCollectionNormalizer;
|
|
88 | 89 | use ApiPlatform\Laravel\Eloquent\PropertyAccess\PropertyAccessor as EloquentPropertyAccessor;
|
89 | 90 | use ApiPlatform\Laravel\Eloquent\PropertyInfo\EloquentExtractor;
|
90 | 91 | use ApiPlatform\Laravel\Eloquent\Serializer\EloquentNameConverter;
|
91 |
| -use ApiPlatform\Laravel\Eloquent\Serializer\Mapping\Loader\RelationMetadataLoader; |
92 | 92 | use ApiPlatform\Laravel\Eloquent\Serializer\SerializerContextBuilder as EloquentSerializerContextBuilder;
|
93 | 93 | use ApiPlatform\Laravel\GraphQl\Controller\EntrypointController as GraphQlEntrypointController;
|
94 | 94 | use ApiPlatform\Laravel\GraphQl\Controller\GraphiQlController;
|
@@ -403,8 +403,25 @@ public function register(): void
|
403 | 403 |
|
404 | 404 | $this->app->bind(ProviderInterface::class, ContentNegotiationProvider::class);
|
405 | 405 |
|
406 |
| - $this->app->singleton(RespondProcessor::class, function () { |
407 |
| - return new AddLinkHeaderProcessor(new RespondProcessor(), new HttpHeaderSerializer()); |
| 406 | + $this->app->singleton(RespondProcessor::class, function (Application $app) { |
| 407 | + $decorated = new RespondProcessor(); |
| 408 | + if (class_exists(AddHeadersProcessor::class)) { |
| 409 | + /** @var ConfigRepository */ |
| 410 | + $config = $app['config']->get('api-platform.http_cache') ?? []; |
| 411 | + |
| 412 | + $decorated = new AddHeadersProcessor( |
| 413 | + $decorated, |
| 414 | + etag: $config['etag'] ?? false, |
| 415 | + maxAge: $config['max_age'] ?? null, |
| 416 | + sharedMaxAge: $config['shared_max_age'] ?? null, |
| 417 | + vary: $config['vary'] ?? null, |
| 418 | + public: $config['public'] ?? null, |
| 419 | + staleWhileRevalidate: $config['stale_while_revalidate'] ?? null, |
| 420 | + staleIfError: $config['stale_if_error'] ?? null |
| 421 | + ); |
| 422 | + } |
| 423 | + |
| 424 | + return new AddLinkHeaderProcessor($decorated, new HttpHeaderSerializer()); |
408 | 425 | });
|
409 | 426 |
|
410 | 427 | $this->app->singleton(SerializeProcessor::class, function (Application $app) {
|
@@ -555,7 +572,8 @@ public function register(): void
|
555 | 572 | $app->make(LoggerInterface::class),
|
556 | 573 | $app->make(ResourceMetadataCollectionFactoryInterface::class),
|
557 | 574 | $app->make(ResourceAccessCheckerInterface::class),
|
558 |
| - $defaultContext |
| 575 | + $defaultContext, |
| 576 | + // $app->make(TagCollectorInterface::class) |
559 | 577 | );
|
560 | 578 | });
|
561 | 579 |
|
@@ -603,6 +621,7 @@ public function register(): void
|
603 | 621 | $defaultContext,
|
604 | 622 | $app->make(ResourceMetadataCollectionFactoryInterface::class),
|
605 | 623 | $app->make(ResourceAccessCheckerInterface::class),
|
| 624 | + // $app->make(TagCollectorInterface::class), |
606 | 625 | );
|
607 | 626 | });
|
608 | 627 |
|
@@ -848,7 +867,6 @@ public function register(): void
|
848 | 867 | $defaultContext,
|
849 | 868 | $app->make(ResourceMetadataCollectionFactoryInterface::class),
|
850 | 869 | $app->make(ResourceAccessCheckerInterface::class),
|
851 |
| - null |
852 | 870 | // $app->make(TagCollectorInterface::class),
|
853 | 871 | );
|
854 | 872 | });
|
@@ -943,7 +961,8 @@ public function register(): void
|
943 | 961 | $app->make(NameConverterInterface::class),
|
944 | 962 | $app->make(ClassMetadataFactoryInterface::class),
|
945 | 963 | $defaultContext,
|
946 |
| - $app->make(ResourceAccessCheckerInterface::class) |
| 964 | + $app->make(ResourceAccessCheckerInterface::class), |
| 965 | + // $app->make(TagCollectorInterface::class) |
947 | 966 | );
|
948 | 967 | });
|
949 | 968 |
|
|
0 commit comments