getRolesList(); // Start of the file $phpCode = " $values) { $phpCode .= " '{$key}' => [\n"; foreach ($values as $subkey => $value) { $phpCode .= " '{$subkey}' => '{$value}',\n"; } $phpCode .= " ],\n"; } // Close the array $phpCode .= "];\n"; // Write PHP code to a file $filePath = APPPATH . "Config/RBAC/roles.php"; file_put_contents($filePath, $phpCode); } } if (!function_exists('generate_php_permissions_constant')) { function generate_php_permissions_constant() { // Generate the array of keys $array = (new PermisosModel())->getPermissionsList(); // Start of the file $phpCode = " $value) { // Using single quotes to ensure keys/values are emitted as literals $phpCode .= "\t'{$key}' => '{$value}',\n"; } // Close the array $phpCode .= "];\n"; // Write PHP code to a file $filePath = APPPATH . "Config/RBAC/permissions.php"; file_put_contents($filePath, $phpCode); } } if (!function_exists('generate_php_permissions_matrix_constant')) { function generate_php_permissions_matrix_constant() { $matrix = (new GroupModel())->getRolesPermissionMatrix(); // Start of the file $phpCode = " $permissions) { $phpCode .= "\t\"{$role}\" => [\n"; foreach ($permissions as $permission) { $phpCode .= "\t\t\"{$permission}\",\n"; } $phpCode .= "\t],\n"; } // Close the array $phpCode .= "];\n"; // Write PHP code to a file $filePath = APPPATH . "Config/RBAC/permissionMatrix.php"; file_put_contents($filePath, $phpCode); } }