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 serializer optional #1327

Merged

Conversation

WebMamba
Copy link
Contributor

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

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Great chore to get done!

@@ -374,8 +378,6 @@ private function dehydrateValue(mixed $value, LivePropMetadata $propMetadata, ob
}

if (!$this->isValueValidDehydratedValue($value)) {
$badKeys = $this->getNonScalarKeys($value, $propMetadata->getName());
Copy link
Member

Choose a reason for hiding this comment

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

this getNonScalarKeys() is now also unused, so let's remove that too :)

@@ -354,6 +354,10 @@ private function dehydrateValue(mixed $value, LivePropMetadata $propMetadata, ob
}

if ($propMetadata->useSerializerForHydration()) {
if (!interface_exists(NormalizerInterface::class)) {
throw new \LogicException(sprintf('The LiveProp "%s" on component "%s" is using the serializer to hydrate, but the Serializer component is not installed. Try running "composer require symfony/serializer".', $propMetadata->getName(), $parentObject::class));
Copy link
Member

Choose a reason for hiding this comment

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

Let's mention the specific option name:

Suggested change
throw new \LogicException(sprintf('The LiveProp "%s" on component "%s" is using the serializer to hydrate, but the Serializer component is not installed. Try running "composer require symfony/serializer".', $propMetadata->getName(), $parentObject::class));
throw new \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));

@weaverryan weaverryan force-pushed the live-components-make-serializer-optional branch from 92518df to a6f00ea Compare December 17, 2023 17:03
@weaverryan
Copy link
Member

Thanks Matheo~

@weaverryan weaverryan merged commit e502400 into symfony:2.x Dec 17, 2023
5 of 6 checks passed
weaverryan added a commit that referenced this pull request Dec 17, 2023
…ializer (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
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.

2 participants