You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #1341 [LiveComponent] Make LiveComponentHydrator work without Serializer (smnandre)
This PR was squashed before being merged into the 2.x branch.
Discussion
----------
[LiveComponent] Make LiveComponentHydrator work without Serializer
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | yes
| License | MIT
Allow nullable "serializer" argument in LiveComponentHydrator constructor.
(fix#1340 and complete #1327)
Commits
-------
10ca442 [LiveComponent] Make LiveComponentHydrator work without Serializer
@@ -357,8 +357,14 @@ private function dehydrateValue(mixed $value, LivePropMetadata $propMetadata, ob
357
357
if (!interface_exists(NormalizerInterface::class)) {
358
358
thrownew \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but the Serializer component is not installed. Try running "composer require symfony/serializer".', $propMetadata->getName(), $parentObject::class));
359
359
}
360
+
if (null === $this->serializer) {
361
+
thrownew \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but no serializer has been set.', $propMetadata->getName(), $parentObject::class));
362
+
}
363
+
if (!$this->serializerinstanceof NormalizerInterface) {
364
+
thrownew \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but the given serializer does not implement NormalizerInterface.', $propMetadata->getName(), $parentObject::class));
@@ -438,8 +444,14 @@ private function hydrateValue(mixed $value, LivePropMetadata $propMetadata, obje
438
444
if (!interface_exists(DenormalizerInterface::class)) {
439
445
thrownew \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but the Serializer component is not installed. Try running "composer require symfony/serializer".', $propMetadata->getName(), $parentObject::class));
440
446
}
447
+
if (null === $this->serializer) {
448
+
thrownew \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but no serializer has been set.', $propMetadata->getName(), $parentObject::class));
449
+
}
450
+
if (!$this->serializerinstanceof DenormalizerInterface) {
451
+
thrownew \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but the given serializer does not implement DenormalizerInterface.', $propMetadata->getName(), $parentObject::class));
0 commit comments