Download the PHP package dized/module-front-acl without Composer
On this page you can find all versions of the php package dized/module-front-acl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package module-front-acl
DiZed Magento 2 Front ACL Module
ACL System for the Front Part of the Magento 2 project.
A module that will allow you to take full advantage of the front-end ACL capabilities in the modules you develop.
Developed and tested on Magento 2.4 version and PHP 7.4 version.
Key Features:
- Ability to create your own roles and permissions via XML file.
- Ability to set default permissions for each of the roles.
- Ability to set the necessary roles and permissions for each customer in the admin panel.
- Ability to automatically set the default role and permissions for a newly created customer (using a plugin).
- Ability to easily use this functionality for controllers/actions and blocks.
Installation.
IMPORTANT to enable the module in Magento Admin: Admin Panel -> Stores -> Settings -> Configuration -> DiZed Team Extensions -> Front ACL.

Adding Roles and Permissions.
To add new roles or permissions, create the etc/acl_front.xml file in your own project module. You can see an example of a file in this module.
Roles are inserted into the FrontAcl_Role::index resource, permissions are inserted into the FrontAcl_Permission::index resource.
If you want to set the default permissions for some roles, use the FrontAcl_Defaults::index resource. Pay attention to the syntax - Relation_ {RoleCamelCase}::permission_snake_case.
Set customer roles and permissions in admin panel.
To set a role or permissions for a customer through the admin panel, just log in as an administrator and follow the following path: Customers -> All Customers -> Click to "Edit" for a customer in the grid -> Tab Front ACL. Select the required data here and save the customer.

IMPORTANT If the permissions tree is not displayed, it is very likely that you are using a version of Magento with an older version of the jQuery jsTree library. In this case, try using the previous script "view/adminhtml/web/js/customer/permissions-tree.js" version.
Set the default role and permissions for a newly created customer automatically.
If you need to set roles and permissions for a new customer automatically, you can create a plugin for the function: \DiZed\FrontAcl\Plugin\Customer\Api\AccountManagement::getDetectedRole(CustomerInterface $customer). In the body of the function, you need to implement the necessary logic based on the customer object and return the required role as a string. Further, based on this role, default permissions will be automatically taken and applied to the customer.
Use this functionality for controllers/actions and blocks.
To check the role or permissions of a customer in a controller/action you need to implement the \DiZed\FrontAcl\Controller\App\HttpAclActionInterface interface and use the FRONT_ACL_ROLE or FRONT_ACL_PERMISSION constants. You can also use the isFrontClassAllowed() public function to specify more precise conditions.
All these properties are also available for blocks, but you need to implement the \DiZed\FrontAcl\Block\View\Element\AclBlockInterface interface.
Getting a collection of customers with specific roles and permissions.
Just need to use \DiZed\FrontAcl\Helper\Data::getCustomerCollection method instead of standard $this->customerCollectionFactory->create();
Additional useful features.
- For independent work with roles and permissions in your own module: \DiZed\FrontAcl\Api\RoleManagementInterface.
- Get a list of available roles, permissions and some more features: \DiZed\FrontAcl\Helper\Data.
- Add work with permission constants to your own class: \DiZed\FrontAcl\Helper\Traits\Acl.