I’ve been trying to figure out the difference between acl
and aclResource
both attributes available for <block>
directive.
I know that aclResource is useful to render the block based on specific acl resource_id example :
<block name="my_block" aclResource="Some_Module::default">
see example in magento
I see that the same attribute is also used in blocks inside ui_components like following :
<uiComponent name="notification_area" aclResource="Magento_AdminNotification::show_list"/>
see example in magento
Now by looking at the XSD file of layout for block handle I see acl and aclResource for the block type
<xs:complexType name="blockType" mixed="true">
<xs:annotation>
<xs:documentation>
....
</xs:sequence>
<xs:attribute type="elementNameType" name="name" use="optional"/>
<xs:attribute type="blockClassType" name="class" use="optional"/>
<xs:attribute type="elementAliasType" name="as" use="optional"/>
<xs:attribute type="xs:string" name="template" use="optional"/>
<xs:attribute type="elementPositionType" name="before" use="optional"/>
<xs:attribute type="elementPositionType" name="after" use="optional"/>
<xs:attribute type="elementOutputType" name="output" use="optional"/>
<xs:attribute type="xs:string" name="acl" use="optional"/> <!-- here -->
<xs:attribute type="xs:string" name="aclResource" use="optional"/>
<xs:attribute type="xs:string" name="ifconfig" use="optional"/>
<xs:attribute type="xs:string" name="group" use="optional" />
<xs:attribute type="xs:boolean" name="cacheable" default="true" use="optional"/>
<xs:attribute type="xs:int" name="ttl" use="optional"/>
</xs:complexType>
by searching in magento core for usages of acl="
in blocks but only in customer_form.xml which is a form ui component.
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<htmlContent name="orders_content">
<block acl="Magento_Sales::actions_view" class="MagentoSalesBlockAdminhtmlCustomerOrdersTab" name="orders" />
</htmlContent>
<htmlContent name="cart_content">
<block acl="Magento_Cart::manage" class="MagentoSalesBlockAdminhtmlShoppingCartsTab" name="cart"/>
</htmlContent>
</form>
All that said, my question(s) is :
does acl and aclResource do the same ? is there any rule or best practice to use one above the other ? is acl deprecated ?