13
13
14
14
namespace ApiPlatform \GraphQl \Subscription ;
15
15
16
+ use ApiPlatform \GraphQl \Resolver \Stage \SerializeStage ;
16
17
use ApiPlatform \GraphQl \Resolver \Stage \SerializeStageInterface ;
17
18
use ApiPlatform \GraphQl \Resolver \Util \IdentifierTrait ;
18
19
use ApiPlatform \Metadata \GraphQl \Operation ;
@@ -37,8 +38,11 @@ final class SubscriptionManager implements OperationAwareSubscriptionManagerInte
37
38
use ResourceClassInfoTrait;
38
39
use SortTrait;
39
40
40
- public function __construct (private readonly CacheItemPoolInterface $ subscriptionsCache , private readonly SubscriptionIdentifierGeneratorInterface $ subscriptionIdentifierGenerator , private readonly ? SerializeStageInterface $ serializeStage , private readonly IriConverterInterface $ iriConverter, private readonly ResourceMetadataCollectionFactoryInterface $ resourceMetadataCollectionFactory , private readonly ?ProcessorInterface $ normalizeProcessor = null )
41
+ public function __construct (private readonly CacheItemPoolInterface $ subscriptionsCache , private readonly SubscriptionIdentifierGeneratorInterface $ subscriptionIdentifierGenerator , private readonly SerializeStageInterface | ProcessorInterface | null $ serializeStage = null , private readonly ? IriConverterInterface $ iriConverter = null , private readonly ?ResourceMetadataCollectionFactoryInterface $ resourceMetadataCollectionFactory = null )
41
42
{
43
+ if (!$ serializeStage instanceof ProcessorInterface) {
44
+ trigger_deprecation ('api-platform/core ' , '4.0 ' , sprintf ('Using an instanceof "%s" is deprecated, use "%s" instead. ' , SerializeStageInterface::class, ProcessorInterface::class));
45
+ }
42
46
}
43
47
44
48
public function retrieveSubscriptionId (array $ context , ?array $ result , ?Operation $ operation = null ): ?string
@@ -85,9 +89,9 @@ public function getPushPayloads(object $object): array
85
89
$ resolverContext = ['fields ' => $ subscriptionFields , 'is_collection ' => false , 'is_mutation ' => false , 'is_subscription ' => true ];
86
90
/** @var Operation */
87
91
$ operation = (new Subscription ())->withName ('update_subscription ' )->withShortName ($ shortName );
88
- if ($ this ->normalizeProcessor ) {
89
- $ data = $ this ->normalizeProcessor ->process ($ object , $ operation , [], $ resolverContext );
90
- } elseif ($ this ->serializeStage ) {
92
+ if ($ this ->serializeStage instanceof ProcessorInterface ) {
93
+ $ data = $ this ->serializeStage ->process ($ object , $ operation , [], $ resolverContext );
94
+ } elseif ($ this ->serializeStage instanceof SerializeStage ) {
91
95
$ data = ($ this ->serializeStage )($ object , $ resourceClass , $ operation , $ resolverContext );
92
96
} else {
93
97
throw new \LogicException ();
0 commit comments