Skip to content

[Twig][Live] Native attributes #255

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
Feb 4, 2022
Merged

Conversation

kbond
Copy link
Member

@kbond kbond commented Jan 31, 2022

Q A
Bug fix? no
New feature? yes
Tickets n/a
License MIT

This removes the need for the HasAttributesTrait that was introduced in #220. Attributes are now "a thing all component have".

ComponentFactory::create() returns a new MountedComponent object that holds the "mounted" component, attributes and component metadata. LiveComponentHydrator::dehydrate() now accepts an instance of MountedComponent and LiveComponentHydrator::hydrate() now returns an instance of MountedComponent.

If the component is live, any attributes are dehydrated/hydrated as "readonly" data (they can't be modified by the frontend).

TODO

  • Update docs referring to HasAttributesTrait

@kbond kbond force-pushed the native-attributes-1 branch from ce4d954 to 53ec97f Compare January 31, 2022 20:00
@kbond
Copy link
Member Author

kbond commented Feb 2, 2022

@seb-jean, you've been experimenting with attribute system added in #220, what do you think of this PR?

@seb-jean
Copy link
Contributor

seb-jean commented Feb 2, 2022

I think this PR is a good idea.

@kbond kbond force-pushed the native-attributes-1 branch 2 times, most recently from dfdbb3a to 2bcbc62 Compare February 3, 2022 19:21
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.

I think this is good. It introduces MountedComponent, but that feels ok to me. 👍 for mer personally

$metadata,
array_merge(['this' => $component], get_object_vars($component))
);
$event = new PreRenderEvent($mounted, $this->factory->metadataFor($mounted->getName()));
Copy link
Member Author

Choose a reason for hiding this comment

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

Requiring the service here is a bit unfortunate.

@kbond kbond force-pushed the native-attributes-1 branch from d79f435 to 37acff2 Compare February 4, 2022 14:34
@weaverryan
Copy link
Member

Thanks Kevin!

@weaverryan weaverryan merged commit 82f18ba into symfony:2.x Feb 4, 2022
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.

3 participants