Support for @aware in Blade Component Class #56704
Replies: 2 comments
-
That’s a very solid use case. Right now $aware only works inside the Blade view itself, which indeed forces you to re-pass data when you want to expose it from the class. |
Beta Was this translation helpful? Give feedback.
-
@Nabil-nl Thank you for the feedback. @inxilpro Hi Chris, any chance you remember when you worked on the original |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Context why I am asking for the feature
We are hoping to adopt Blade templating system in our OJS opensource software publishing software.
As part of that process I was hoping to create good components abstraction, inspired by headless components (like reka-ui). To abstract out correct semantic html, some business logic and data extraction to these components. And let developer just focus on styling and organising the components - to be able to create very custom themes.
While working on good api design, I have run into the problem, where I am not unable to use
aware
inside component class to be able to access the data in the class itself.Example when this would be useful
In this case I am able to access the
$author
inx-author.full-name
, because I don't need component class. But forx-author.affiliations
I need to be able to expose the array ofaffiliations
on the$component
and for that I need the class and need to be able to access$author
in that class. Currently only way to achieve this is to pass the $author again to thex-author.affiliations
, which would be very confusing, why some components needs it and some don't.Proposed feature
Bring the $aware functionality to the class components. My understanding is that this option was considered originally when this feature was worked on - #39100 (comment) . And @taylorotwell decided not to include it at that time. And I am hoping this could be reconsidered to allow some of these abstractions.
To me this came as big surprise while working on this - that I can access it only from child view. As I would consider component as part of the "child component".
Would PR for this addition be accepted?
Thank you for the feedback!
Beta Was this translation helpful? Give feedback.
All reactions