use \ACLC\ACLController; $acl = new ACLController(); $acl->addRole('admin'); $acl->addRole('user', 'admin'); $acl->addResource('dashboard'); $acl->addResource('view_profile'); $acl->addResource('edit_profile'); $acl->allow('admin', 'dashboard', ['view', 'edit']); $acl->allow('user', 'view_profile'); $acl->allow('user', 'edit_profile', function($user_id, $resource_id) { // Complex logic to determine if the user can edit their own profile return ($user_id == $resource_id); });
use \ACLC\ACLController; $userId = 123; $resourceId = 456; $action = 'edit_profile'; $acl = new ACLController(); if ($acl->check($userId, $resourceId, $action)) { // User has permission to perform the action on the resource // Proceed with action... } else { // User does not have permission to perform the action on the resource // Redirect to error page... }This code checks if the user with ID `123` has permission to `edit` their own profile resource with ID `456`. If the user has permission, the code can proceed with the action, otherwise it redirects to an error page. Overall, the ACLController is a powerful and easy-to-use package library for managing user permissions and roles in web applications.