43
43
use ApiPlatform \GraphQl \Type \TypesContainerInterface ;
44
44
use ApiPlatform \GraphQl \Type \TypesFactory ;
45
45
use ApiPlatform \GraphQl \Type \TypesFactoryInterface ;
46
+ use ApiPlatform \Hal \Serializer \CollectionNormalizer as HalCollectionNormalizer ;
47
+ use ApiPlatform \Hal \Serializer \EntrypointNormalizer as HalEntrypointNormalizer ;
48
+ use ApiPlatform \Hal \Serializer \ItemNormalizer as HalItemNormalizer ;
49
+ use ApiPlatform \Hal \Serializer \ObjectNormalizer as HalObjectNormalizer ;
46
50
use ApiPlatform \Hydra \JsonSchema \SchemaFactory as HydraSchemaFactory ;
47
51
use ApiPlatform \Hydra \Serializer \CollectionFiltersNormalizer as HydraCollectionFiltersNormalizer ;
48
52
use ApiPlatform \Hydra \Serializer \CollectionNormalizer as HydraCollectionNormalizer ;
@@ -660,6 +664,43 @@ public function register(): void
660
664
);
661
665
});
662
666
667
+ $ this ->app ->singleton (HalCollectionNormalizer::class, function (Application $ app ) {
668
+ /** @var ConfigRepository */
669
+ $ config = $ app ['config ' ];
670
+
671
+ return new HalCollectionNormalizer (
672
+ $ app ->make (ResourceClassResolverInterface::class),
673
+ $ config ->get ('api-platform.pagination.page_parameter_name ' ),
674
+ $ app ->make (ResourceMetadataCollectionFactoryInterface::class),
675
+ );
676
+ });
677
+
678
+ $ this ->app ->singleton (HalObjectNormalizer::class, function (Application $ app ) {
679
+ return new HalObjectNormalizer (
680
+ $ app ->make (ObjectNormalizer::class),
681
+ $ app ->make (IriConverterInterface::class)
682
+ );
683
+ });
684
+
685
+ $ this ->app ->singleton (HalItemNormalizer::class, function (Application $ app ) {
686
+ /** @var ConfigRepository */
687
+ $ config = $ app ['config ' ];
688
+ $ defaultContext = $ config ->get ('api-platform.serializer ' , []);
689
+
690
+ return new HalItemNormalizer (
691
+ $ app ->make (PropertyNameCollectionFactoryInterface::class),
692
+ $ app ->make (PropertyMetadataFactoryInterface::class),
693
+ $ app ->make (IriConverterInterface::class),
694
+ $ app ->make (ResourceClassResolverInterface::class),
695
+ $ app ->make (PropertyAccessorInterface::class),
696
+ $ app ->make (NameConverterInterface::class),
697
+ $ app ->make (ClassMetadataFactoryInterface::class),
698
+ $ defaultContext ,
699
+ $ app ->make (ResourceMetadataCollectionFactoryInterface::class),
700
+ $ app ->make (ResourceAccessCheckerInterface::class),
701
+ );
702
+ });
703
+
663
704
$ this ->app ->singleton (Options::class, function (Application $ app ) {
664
705
/** @var ConfigRepository */
665
706
$ config = $ app ['config ' ];
@@ -922,6 +963,10 @@ public function register(): void
922
963
$ list = new \SplPriorityQueue ();
923
964
$ list ->insert ($ app ->make (HydraEntrypointNormalizer::class), -800 );
924
965
$ list ->insert ($ app ->make (HydraPartialCollectionViewNormalizer::class), -800 );
966
+ $ list ->insert ($ app ->make (HalCollectionNormalizer::class), -800 );
967
+ $ list ->insert ($ app ->make (HalEntrypointNormalizer::class), -985 );
968
+ $ list ->insert ($ app ->make (HalObjectNormalizer::class), -995 );
969
+ $ list ->insert ($ app ->make (HalItemNormalizer::class), -890 );
925
970
$ list ->insert ($ app ->make (JsonLdItemNormalizer::class), -890 );
926
971
$ list ->insert ($ app ->make (JsonLdObjectNormalizer::class), -995 );
927
972
$ list ->insert ($ app ->make (ArrayDenormalizer::class), -990 );
@@ -950,10 +995,6 @@ public function register(): void
950
995
// TODO: unused + implement hal/jsonapi ?
951
996
// $list->insert($dataUriNormalizer, -920);
952
997
// $list->insert($unwrappingDenormalizer, 1000);
953
- // $list->insert($halItemNormalizer, -890);
954
- // $list->insert($halEntrypointNormalizer, -800);
955
- // $list->insert($halCollectionNormalizer, -985);
956
- // $list->insert($halObjectNormalizer, -995);
957
998
// $list->insert($jsonserializableNormalizer, -900);
958
999
// $list->insert($uuidDenormalizer, -895); //Todo ramsey uuid support ?
959
1000
@@ -964,6 +1005,7 @@ public function register(): void
964
1005
$ app ->make (JsonEncoder::class),
965
1006
new JsonEncoder ('jsonopenapi ' ),
966
1007
new JsonEncoder ('jsonapi ' ),
1008
+ new JsonEncoder ('jsonhal ' ),
967
1009
new CsvEncoder (),
968
1010
]);
969
1011
});
0 commit comments