@@ -73,7 +73,7 @@ final class PublishMercureUpdatesListener
73
73
* @param array<string, string[]|string> $formats
74
74
* @param HubRegistry|callable $hubRegistry
75
75
*/
76
- public function __construct (ResourceClassResolverInterface $ resourceClassResolver , IriConverterInterface $ iriConverter , $ resourceMetadataFactory , SerializerInterface $ serializer , array $ formats , MessageBusInterface $ messageBus = null , $ hubRegistry = null , ?GraphQlSubscriptionManagerInterface $ graphQlSubscriptionManager = null , ?GraphQlMercureSubscriptionIriGeneratorInterface $ graphQlMercureSubscriptionIriGenerator = null , ExpressionLanguage $ expressionLanguage = null )
76
+ public function __construct (ResourceClassResolverInterface $ resourceClassResolver , IriConverterInterface $ iriConverter , ResourceMetadataCollectionFactoryInterface $ resourceMetadataFactory , SerializerInterface $ serializer , array $ formats , MessageBusInterface $ messageBus = null , $ hubRegistry = null , ?GraphQlSubscriptionManagerInterface $ graphQlSubscriptionManager = null , ?GraphQlMercureSubscriptionIriGeneratorInterface $ graphQlMercureSubscriptionIriGenerator = null , ExpressionLanguage $ expressionLanguage = null )
77
77
{
78
78
if (null === $ messageBus && null === $ hubRegistry ) {
79
79
throw new InvalidArgumentException ('A message bus or a hub registry must be provided. ' );
@@ -173,14 +173,10 @@ private function storeObjectToPublish($object, string $property): void
173
173
return ;
174
174
}
175
175
176
- if ($ this ->resourceMetadataFactory instanceof ResourceMetadataCollectionFactoryInterface) {
177
- try {
178
- $ options = $ this ->resourceMetadataFactory ->create ($ resourceClass )->getOperation ()->getMercure ();
179
- } catch (OperationNotFoundException $ e ) {
180
- return ;
181
- }
182
- } else {
183
- $ options = $ this ->resourceMetadataFactory ->create ($ resourceClass )->getAttribute ('mercure ' , false );
176
+ try {
177
+ $ options = $ this ->resourceMetadataFactory ->create ($ resourceClass )->getOperation ()->getMercure () ?? false ;
178
+ } catch (OperationNotFoundException $ e ) {
179
+ return ;
184
180
}
185
181
186
182
if (\is_string ($ options )) {
@@ -273,12 +269,7 @@ private function publishUpdate($object, array $options, string $type): void
273
269
$ data = json_encode (['@id ' => $ object ->id ]);
274
270
} else {
275
271
$ resourceClass = $ this ->getObjectClass ($ object );
276
- if ($ this ->resourceMetadataFactory instanceof ResourceMetadataCollectionFactoryInterface) {
277
- $ context = $ options ['normalization_context ' ] ?? $ this ->resourceMetadataFactory ->create ($ resourceClass )->getOperation ()->getNormalizationContext ();
278
- } else {
279
- // TODO: remove in 3.0
280
- $ context = $ options ['normalization_context ' ] ?? $ this ->resourceMetadataFactory ->create ($ resourceClass )->getAttribute ('normalization_context ' , []);
281
- }
272
+ $ context = $ options ['normalization_context ' ] ?? $ this ->resourceMetadataFactory ->create ($ resourceClass )->getOperation ()->getNormalizationContext ();
282
273
283
274
$ iri = $ options ['topics ' ] ?? $ this ->iriConverter ->getIriFromItem ($ object , null , UrlGeneratorInterface::ABS_URL );
284
275
$ data = $ options ['data ' ] ?? $ this ->serializer ->serialize ($ object , key ($ this ->formats ), $ context );
0 commit comments