-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Allows modules with underscores in name to add blocks to layout via XML #11765
Allows modules with underscores in name to add blocks to layout via XML #11765
Conversation
@@ -138,7 +138,7 @@ | |||
|
|||
<xs:simpleType name="blockClassType"> | |||
<xs:restriction base="xs:string"> | |||
<xs:pattern value="[A-Z][a-zA-Z\d]*(\\[A-Z][a-zA-Z\d]*)*"/> | |||
<xs:pattern value="[A-Z][a-zA-Z\d]*(\\[A-Z][_a-zA-Z\d]*)*"/> |
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.
For consistency with other places, like https://github.com/magento/magento2/pull/11650/files, were underscore was allowed previously, please allow underscore in vendor name also, perform an amend commit and force push into the same branch.
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.
I have made this change. Now both Vendor and Module allow underscores.
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.
Changes look good now. Just squash all changes into single commit and do a force push to the same branch please.
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.
I think I have done this but let me know if I've made a mistake or you need anything else.
Amended to allow underscore in Vendor name as well as module name
Just a quick update but I have found the same issue in the XSD file that handles the system.xml configuration options. I have created a new pull request that supplies the same fix as this (adding the underscore to the regular expression). The new pull request can be seen at #14397 |
Allow modules with underscores in the name to add blocks to the layout using XML.
Description
Magento 2 allows module names to include the underscore character (Vendor_Module_Name, which is app/code/Vendor/Module_Name) but doesn't then allow the module to add a block to the layout via XML.
This only occurs in developer mode and produces the following error:
The facet pattern is defined in lib/internal/Magento/Framework/View/Layout/etc/elements.xsd:
This pattern does not allow the underscore character to appear in the block class type attribute. I have fixed this by changing the pattern to:
<xs:pattern value="[A-Z][a-zA-Z\d]*(\\[A-Z][_a-zA-Z\d]*)*"/>
This allows an underscore to be used in the module name. This could be further to changed to allow an underscore to be used in the vendor name by changing it to:
<xs:pattern value="[A-Z][_a-zA-Z\d]*(\\[A-Z][_a-zA-Z\d]*)*"/>
Manual testing scenarios