Replies: 1 comment
-
OK, based on @mvenghaus MR #79, I've created a new branch https://github.com/magewirephp/magewire/tree/feature/dynamic-layout-v2. Within this branch, I've did a ton of experimenting on how the architecture could look like. I came up with a resolver structure where blocks can comply on one or multiple (lightweight) conditions. When true is returned, that resolver is used to construct and reconstruct the component.
Reconstruction will. be handed thanks to a new trait I've added to the base component. This trait can hold the used ResolverInterface. Thanks to this, we can glue a so called "public name" onto the request fingerprint. During a subsequent request, this public name will be used to search the related ResolverInterface and reconstruct's the component based on all the data coming along with the subsequent request post data. Files:
Components are being (re-) constructed at three particular points.
Since Magewire initially only worked with Layout XML files, the Layout Resolver is the default fallback which can be changed if that would be desirable in the future. To support other types of components, like e.g. Widgets, we need a second Widget Resolver which can recognize Widgets based on the required Widget Then, to make Widgets be picked up by Magewire, the Block data needs a 'magewire' parameter because this is the only gateway into Magewire. Making this any heavier would not benefit all the other blocks that are being loaded during a preceding request. To accomplice this, I came up with an idea.
Why this way? Well, the widget ID is not used anywhere else in the widget process. So I've searched for a spot where I do still have the widget ID. Because the type is
This sounds a bit complex, but in my eyes it's the only solid way to support multiple ways of constructing blocks with a Magewire component. Because it requires quite a lot of code, I think the widget resolver including all other logic should go into a separate Now my question to those interested: would this be a workable way without to much complexity. When implemented, it would only require one thing.
|
Beta Was this translation helpful? Give feedback.
-
Currently it is only possible to use magewire in layout xml files. I needed this for dynamic created blocks in templates and widgets. Here is my solution:
#79
Beta Was this translation helpful? Give feedback.
All reactions