Permission

class Nos\User\Permission

This class checks the permissions for the current logged in user.

When multiple roles are enable, if any role has the requested permission, it means the user is authorised to do it.

static Nos\User\Permission::check($permission_name, $category_key = null, $allow_empty = false)

Alias to Nos\User\Permission::exists

static Nos\User\Permission::exists($permission_name, $category_key = null, $allow_empty = false)

Check whether a permissions exists (against all the roles of the current logged in user).

Parameters:
  • $permission_name (string) – Name of the permission to check against
  • $category_key (string) – (optional) If the permission has categories, the category key to check against
  • $allow_empty (bool) – (optional) Should we grant access when nothing is configured?
Returns bool:

true or false

static Nos\User\Permission::existsOrEmpty($permission_name, $category_key = null, $allow_empty = false)

Alias to Nos\User\Permission::exists with the optional parameter $alowEmpty = true.

Parameters:
  • $permission_name (string) – Name of the permission to check against
  • $category_key (string) – (optional) If the permission has categories, the category key to check against
Returns bool:

true or false

static Nos\User\Permission::isAllowed($permission_name, $allow_empty = false)

Check against a binary permission (without categories) against all the roles of the current logged in user.

Parameters:
  • $permission_name (string) – Name of the permission
  • $allow_empty (bool) – Should we grant access when nothing is configured?
Returns bool:

true or false

static Nos\User\Permission::atLeast($permission_name, $threshold, $value_when_empty = 0)

Check against a numeric / range permission (for all the roles of the current logged in user).

You can use string for the 2nd and 3rd parameters, they will be casted to (int). i.e. '2_write' === 2.

Parameters:
  • $permission_name (string) – Name of the permission
  • $threshold (int) – Minimum value to grant access
  • $value_when_empty (int) – Default value to compare with when nothing is configured
Returns bool:

true or false

static Nos\User\Permission::atMost($permission_name, $threshold, $value_when_empty = 0)

Check against a numeric / range permission (for all the roles of the current logged in user).

You can use string for the 2nd and 3rd parameters, they will be casted to (int). i.e. '2_write' === 2.

Parameters:
  • $permission_name (string) – Name of the permission
  • $threshold (int) – Maximum value to grant access
  • $value_when_empty (int) – Default value to compare with when nothing is configured
Returns bool:

true or false

static Nos\User\Permission::listPermissionCategories($permission_name)

List all the categories of a given permission name (merged values from all the roles of the current logged in user).

Returns an array of string or false when access is denied, or the permission name does not exists.

Parameters:
  • $permission_name (string) – The name of the permission to retrieve categories from
Returns array|false:
 

An array containing the list of categories (values) for the requested permission name

static Nos\User\Permission::isApplicationAuthorised($application_name)

Check whether a user can access a particular application

Parameters:
  • $application_name (string) – Name of the application :returns bool: true or false
static Nos\User\Permission::contexts

Returns an array of all the contexts the user can access.

static Nos\User\Permission::locales

Returns an array of all the locales the user can access.

static Nos\User\Permission::sites

Returns an array of all the sites the user can access.

Read the Docs v: elche
Versions
latest
stable
elche
dubrovka
chiba.2
chiba.1
Downloads
pdf
htmlzip
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.