Overview
ThePermissions class manages a collection of module permissions for an entity. It provides methods to check permission existence, retrieve individual permissions, and manage the permission list.
Constructor
Creates a new Permissions instance with a permission list.Array of permissions indexed by module code. Each permission contains:
i(int): Permission IDd(string): Module developing status (‘0’ or ‘1’)f(array): Feature codes (e.g., [‘0’, ‘1’, ‘2’] for create, read, update)l(int): Permission level
Typically, you don’t instantiate this directly. Use
GAC::getPermissions() instead.Methods
has()
Checks if permission exists for a specific module.The unique code identifying the module (e.g.,
'invoices', 'products', 'users')Returns
true if the entity has permission to access the module, false otherwiseget()
Retrieves a Permission instance for a specific module.The unique code identifying the module
Returns a
Permission instance with permission details, or null if no permission existsException if permission data is invalid
getList()
Returns the complete permission list.Array of all permissions indexed by module code
setList()
Replaces the entire permission list.New permission array to replace the current list
Returns the Permissions instance for method chaining
Permission Data Structure
Each permission in the list follows this structure:Permission record ID from the database
Module development status:
'0' (stable) or '1' (developing)Array of feature codes:
'0': create'1': read'2': update'3': delete'4': trash'5': dev
Permission level (numeric value indicating access tier)
Usage Examples
Basic Permission Check
Detailed Permission Inspection
Conditional UI Rendering
Permission Caching Pattern
See Also
- Permission - Individual permission object
- GAC - Main GAC class reference
- Checking Permissions Guide - Practical usage guide