The app/code/Foggyline/Helpdesk/etc/acl.xml
file is where we define our module access control list resources. Access control list resources are visible under the Magento admin System | Permissions | User Roles area, when we click on the Add New Role button, as shown in the following screenshot:
Looking at the preceding screenshot, we can see our Helpdesk Section under Stores | Settings | Configuration. How did we put it there? We have defined it in our app/code/Foggyline/Helpdesk/etc/acl.xml
file with content as follows:
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/ etc/acl.xsd"> <acl> <resources> <resource id="Magento_Backend::admin"> <resource id="Magento_Customer::customer"> <resource id="Foggyline_Helpdesk:: ticket_manage" title="Manage Helpdesk Tickets" /> </resource> <resource id="Magento_Backend::stores"> <resource id="Magento_Backend:: stores_settings"> <resource id="Magento_Config::config"> <resource id= "Foggyline_Helpdesk::helpdesk" title="Helpdesk Section" /> </resource> </resource> </resource> </resource> </resources> </acl> </config>
Looking at the provided code, the immediate conclusion is that resources can be nested into each other. It is unclear how we should know where to nest our custom-defined resource with an ID value of Foggyline_Helpdesk::helpdesk
. The simple answer is we followed the Magento structure. By looking into a few of the Magento core modules system.xml
files and their acl.xml
files, a pattern emerged where modules nest their resource under Magento_Backend::admin
| Magento_Backend::stores
| Magento_Backend::stores_settings
| Magento_Config::config
. These are all existing resources defined in core Magento, so we are merely referencing them, not defining them. The only resource we are defining in our acl.xml
file is our own, which we are then referencing from our system.xml
file. We can define other resources within acl.xml
and not all would be nested into the same structure as Foggyline_Helpdesk::helpdesk
.
The value of the title
attribute we assign to a resource element is shown in the admin area, as in the previous screenshot.
18.188.152.162