-
-
Notifications
You must be signed in to change notification settings - Fork 924
Description
API Platform version(s) affected: 4.1.7
Description
Mercure doesn't use entity's state provider when publishing updates
How to reproduce
Let's say you've this in your operations:
new Get(
provider: ExampleProvider::class,
),
and your ExampleProvider
returns a calculated field or extra data from another database.
Mercure publish update listener simply doesn't take into account entity's provider.
Possible Solution
Looks like it's only supports seriliazer:
core/src/Symfony/Doctrine/EventListener/PublishMercureUpdatesListener.php
Lines 242 to 249 in f48a2be
$resourceClass = $this->getObjectClass($object); | |
$context = $options['normalization_context'] ?? $this->resourceMetadataFactory->create($resourceClass)->getOperation()->getNormalizationContext() ?? []; | |
// We need to evaluate it here, because in storeObjectToPublish() the resource would not have been persisted yet | |
$this->evaluateTopics($options, $object); | |
$iri = $options['topics'] ?? $this->iriConverter->getIriFromResource($object, UrlGeneratorInterface::ABS_URL); | |
$data = $options['data'] ?? $this->serializer->serialize($object, key($this->formats), $context); |
Additional Context
Thanks!
soyuka and unguul
Metadata
Metadata
Assignees
Labels
No labels