Skip to content

[LiveComponent] Make LiveComponentHydrator work without Serializer #1341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

smnandre
Copy link
Member

Q A
Bug fix? yes
New feature? yes
License MIT

Allow nullable "serializer" argument in LiveComponentHydrator constructor.

(fix #1340 and complete #1327)

Copy link
Contributor

@WebMamba WebMamba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups super sorry about that! Thanks a lot @smnandre

Comment on lines +360 to +365
if (null === $this->serializer) {
throw new \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but no serializer has been set.', $propMetadata->getName(), $parentObject::class));
}
if (!$this->serializer instanceof NormalizerInterface) {
throw new \LogicException(sprintf('The LiveProp "%s" on component "%s" has "useSerializerForHydration: true", but the given serializer does not implement NormalizerInterface.', $propMetadata->getName(), $parentObject::class));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need those two errors? How those two errors could happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null test is required (it's not because symfony/serializer is installed that it is configured in Symfony).

The instance test is necessary because the constructor argument is NormalizerInterface|DenormalizerInterface .. so one could be normalizer without beeing denormalizer :|

@weaverryan weaverryan force-pushed the fix/hydrator-serializer branch from 363cfae to 10ca442 Compare December 17, 2023 22:16
@weaverryan
Copy link
Member

Thanks Simon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LiveComponent] Serializer still required
3 participants