1515
1616use ApiPlatform \Serializer \CacheableSupportsMethodInterface ;
1717use Symfony \Component \Serializer \Exception \LogicException ;
18+ use Symfony \Component \Serializer \Normalizer \CacheableSupportsMethodInterface as BaseCacheableSupportsMethodInterface ;
1819use Symfony \Component \Serializer \Normalizer \DenormalizerInterface ;
1920use Symfony \Component \Serializer \Normalizer \NormalizerInterface ;
2021use Symfony \Component \Serializer \SerializerAwareInterface ;
@@ -39,8 +40,10 @@ public function __construct(private readonly NormalizerInterface $decorated)
3940 */
4041 public function hasCacheableSupportsMethod (): bool
4142 {
42- if (!$ this ->decorated instanceof CacheableSupportsMethodInterface) {
43- throw new LogicException (sprintf ('The decorated normalizer must be an instance of "%s". ' , CacheableSupportsMethodInterface::class));
43+ trigger_deprecation ('api-platform/core ' , '3.1 ' , 'The "%s()" method is deprecated, use "getSupportedTypes()" instead. ' , __METHOD__ );
44+
45+ if (!$ this ->decorated instanceof BaseCacheableSupportsMethodInterface) {
46+ throw new LogicException (sprintf ('The decorated normalizer must be an instance of "%s". ' , BaseCacheableSupportsMethodInterface::class));
4447 }
4548
4649 return $ this ->decorated ->hasCacheableSupportsMethod ();
@@ -96,11 +99,11 @@ public function getSupportedTypes($format): array
9699 if (!method_exists ($ this ->decorated , 'getSupportedTypes ' )) {
97100 return [
98101 DocumentNormalizer::FORMAT => null ,
99- '* ' => $ this ->decorated instanceof CacheableSupportsMethodInterface && $ this ->decorated ->hasCacheableSupportsMethod (),
102+ '* ' => $ this ->decorated instanceof BaseCacheableSupportsMethodInterface && $ this ->decorated ->hasCacheableSupportsMethod (),
100103 ];
101104 }
102105
103- return DocumentNormalizer::FORMAT ! == $ format ? $ this ->decorated ->getSupportedTypes ($ format ) : [];
106+ return DocumentNormalizer::FORMAT = == $ format ? $ this ->decorated ->getSupportedTypes ($ format ) : [];
104107 }
105108
106109 /**
0 commit comments