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

ComponentBinder #470

Closed
g105b opened this issue Oct 18, 2023 · 1 comment · Fixed by #472
Closed

ComponentBinder #470

g105b opened this issue Oct 18, 2023 · 1 comment · Fixed by #472

Comments

@g105b
Copy link
Member

g105b commented Oct 18, 2023

We already have the DocumentBinder. It would be useful to be able to bind to a specific Component.

Following on from my thoughts on PhpGt/ServiceContainer#140, there should continue to be a DocumentBinder, but we should introduce a ComponentBinder that is pre-constrained to a Component, but we should also introduce a Binder class that both DocumentBinder and ComponentBinder extend. This way, the developer could get into the habit of always requesting a Binder, and only reach for the specific instance in the edge case where they need it.

@g105b
Copy link
Member Author

g105b commented Oct 25, 2023

The current implementation of PhpGt/ServiceContainer#140 means that any $extraArgs provided to the invoker will be preferred over what is in the container. This is perfect functionality for the new Binder class - there can be one instance in the Container by default, extending the DocumentBinder as normal, and one passed in to the component's go function, extending the new ComponentBinder class (which is pre-constrained to have the context of the component element).

@g105b g105b mentioned this issue Oct 25, 2023
@g105b g105b linked a pull request Oct 25, 2023 that will close this issue
g105b added a commit that referenced this issue Oct 27, 2023
g105b added a commit that referenced this issue Nov 10, 2023
* build: upgrade dom requirement and loosen version range

* docs: update examples

* feature: trim whitespace when there are only template children
closes #363

* maintenance: phpstorm analysis improvements

* tweak: remove data-element attribute

* feature: implement ComponentBinder and abstract Binder class
for #470

* fix: bindable cache allows nested nullable objects
closes #474

* refactor: all domtemplate classes set their dependencies outside of the constructor
for #470

* tweak: stricter reflection type checking

* wip: better exception on missing list element

* tweak: handle nullable iterables
closes #473

* tweak: handle binding of outer list item

* tidy: improve types and coverage

* ci: php 8.2

* ci: phpstan level 6
@github-project-automation github-project-automation bot moved this to Done November 2023 in Overview Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done November 2023
Development

Successfully merging a pull request may close this issue.

1 participant