-
Notifications
You must be signed in to change notification settings - Fork 152
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
Proposal: Allow class attribute for referenceBlock type in layout xml #85
Conversation
This is called Duck Typing, as the contract of a block is not defined in advance it's defining by the template/child blocks which use it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Structural typing is preferable in OOP in comparison with Duck Typing which this proposal incorporates
@maghamed It is possible to implement structural typing for this proposal by restricting the class defined in |
Absolutely not applicable here as we allow complete removal of a particular node and re-adding it back. This proposal is just a syntactic sugar to avoid something as ugly as https://github.com/magento/magento2/pull/11709/files |
I think this would be a nice addition. This gives layout XML more leverage, that is, once learned, more can be achieved with the tool. |
Agreed this would be a nice addition. Also I don’t believe the ‘con’:
Is any different from a developer currently being able to replace the existing template with one that is not compatible with the block class or that you can add / replace / remove arguments in layout XML that could equally break something. |
Allow class attribute for referenceBlock type in layout xml
Problem
It is impossible to substitute a block class and/or customize block method(s) implementation on a specific page keeping layout configuration of the block (position, sorting in the layout, child blocks, arguments).
Currently available block class substitution approaches do not resolve the problem:
Solution
Allow the
class
attribute ofblockReferenceType
inlib/internal/Magento/Framework/View/Layout/etc/elements.xsd
See: magento/magento2#18933
Pros
Cons
POC
POC is implemented in public pull request: magento/magento2#18933
Requested Reviewers
@leandrommedeiros - contributor
@antonkril
@maghamed
@akaplya
@kandy