Skip to content
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

[LiveComponent] Make LiveComponentHydrator work without Serializer #1341

Merged
merged 1 commit into from
Dec 17, 2023

Conversation

smnandre
Copy link
Collaborator

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

Allow nullable "serializer" argument in LiveComponentHydrator constructor.

(fix #1340 and complete #1327)

Copy link
Collaborator

@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
Collaborator

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
Collaborator 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
Copy link
Member

Thanks Simon!

@weaverryan weaverryan merged commit 11402b9 into symfony:2.x Dec 17, 2023
5 of 6 checks passed
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