1515
1616use ApiPlatform \Metadata \HttpOperation ;
1717use ApiPlatform \Metadata \Resource \Factory \ResourceMetadataCollectionFactoryInterface ;
18+ use ApiPlatform \Serializer \CacheableSupportsMethodInterface ;
1819use ApiPlatform \State \Pagination \PaginatorInterface ;
1920use ApiPlatform \State \Pagination \PartialPaginatorInterface ;
2021use ApiPlatform \Util \IriHelper ;
2122use Symfony \Component \PropertyAccess \PropertyAccess ;
2223use Symfony \Component \PropertyAccess \PropertyAccessorInterface ;
2324use Symfony \Component \Serializer \Exception \UnexpectedValueException ;
24- use Symfony \Component \Serializer \Normalizer \CacheableSupportsMethodInterface ;
25+ use Symfony \Component \Serializer \Normalizer \CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface ;
2526use Symfony \Component \Serializer \Normalizer \NormalizerAwareInterface ;
2627use Symfony \Component \Serializer \Normalizer \NormalizerInterface ;
28+ use Symfony \Component \Serializer \Serializer ;
2729
2830/**
2931 * Adds a view key to the result of a paginated Hydra collection.
@@ -111,7 +113,7 @@ public function getSupportedTypes($format): array
111113 // @deprecated remove condition when support for symfony versions under 6.3 is dropped
112114 if (!method_exists ($ this ->collectionNormalizer , 'getSupportedTypes ' )) {
113115 return [
114- '* ' => $ this ->collectionNormalizer instanceof CacheableSupportsMethodInterface && $ this ->collectionNormalizer ->hasCacheableSupportsMethod (),
116+ '* ' => $ this ->collectionNormalizer instanceof BaseCacheableSupportsMethodInterface && $ this ->collectionNormalizer ->hasCacheableSupportsMethod (),
115117 ];
116118 }
117119
@@ -120,9 +122,16 @@ public function getSupportedTypes($format): array
120122
121123 public function hasCacheableSupportsMethod (): bool
122124 {
123- trigger_deprecation ('api-platform/core ' , '3.1 ' , 'The "%s()" method is deprecated, use "getSupportedTypes()" instead. ' , __METHOD__ );
125+ if (method_exists (Serializer::class, 'getSupportedTypes ' )) {
126+ trigger_deprecation (
127+ 'api-platform/core ' ,
128+ '3.1 ' ,
129+ 'The "%s()" method is deprecated, use "getSupportedTypes()" instead. ' ,
130+ __METHOD__
131+ );
132+ }
124133
125- return $ this ->collectionNormalizer instanceof CacheableSupportsMethodInterface && $ this ->collectionNormalizer ->hasCacheableSupportsMethod ();
134+ return $ this ->collectionNormalizer instanceof BaseCacheableSupportsMethodInterface && $ this ->collectionNormalizer ->hasCacheableSupportsMethod ();
126135 }
127136
128137 /**
0 commit comments