Skip to content

[LiveComponent] Add a required "default" action for live components #116

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
Jul 8, 2021

Conversation

kbond
Copy link
Member

@kbond kbond commented Jul 1, 2021

Q A
Bug fix? no
New feature? yes
Tickets #102 (feature A/D)
License MIT

In order to use the @Security/@Cache annotations for your components, we need the default action to be on the component itself. Currently, for the default action, the component is wrapped inside an internal callable DefaultComponentController object. This won't inherit these annotations from the component class. The best solution @weaverryan and I could think of is to enforce a "default action" method exists on your component itself.

By default, __invoke() is used but this can be customized via the AsLiveComponent::$defaultAction property. A DefaultActionTrait is provided that just adds an empty __invoke() method.

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.

Very nice - even if NEEDING to force the user to have an __invoke() method isn't our favorite (though DefaultActionTrait will help with that)

@kbond kbond force-pushed the default-action branch 2 times, most recently from 48117f4 to c335326 Compare July 2, 2021 18:00
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.

just 2 minor comments about the docs - thanks!

@kbond kbond force-pushed the default-action branch from 5e22d26 to 86ab5ae Compare July 7, 2021 22:54
@kbond kbond requested a review from weaverryan July 7, 2021 22:56
@weaverryan
Copy link
Member

Thanks Kevin!

@weaverryan weaverryan merged commit 004b969 into symfony:main Jul 8, 2021
@kbond kbond deleted the default-action branch July 8, 2021 13:46
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