1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129:
<?php
/**
* MvcCore
*
* This source file is subject to the BSD 3 License
* For the full copyright and license information, please view
* the LICENSE.md file that are distributed with this source code.
*
* @copyright Copyright (c) 2016 Tom Flidr (https://github.com/mvccore)
* @license https://mvccore.github.io/docs/mvccore/5.0.0/LICENCE.md
*/
namespace MvcCore\Ext\Auths\Basics;
/**
* Responsibility - base role model class.
*/
interface IRole {
// trait: \MvcCore\Ext\Auths\Basics\Traits\UserAndRole\Base
/**
* User unique id, representing primary key in database
* or sequence number in system config.
* Example: `0 | 1 | 2...`
* @return int|NULL
*/
public function GetId ();
/**
* Set user unique id, representing primary key in database
* or sequence number in system config.
* Example: `0 | 1 | 2...`
* @param int|NULL $id
* @return \MvcCore\Ext\Auths\Basics\Role
*/
public function SetId ($id);
/**
* Get user active state boolean. `TRUE` for active, `FALSE` otherwise.
* This function is only alias for `$user->GetActive();`.
* @return bool
*/
public function IsActive ();
/**
* Get user active state boolean. `TRUE` for active, `FALSE` otherwise.
* @return bool
*/
public function GetActive ();
/**
* Set user active state boolean. `TRUE` for active, `FALSE` otherwise.
* @return \MvcCore\Ext\Auths\Basics\Role
*/
public function SetActive ($active);
// trait: \MvcCore\Ext\Auths\Basics\Traits\UserAndRole\Permissions
/**
* Get `TRUE` if given permission string is allowed for user or role. `FALSE` otherwise.
* @param string $permissionName
* @return bool
*/
public function GetPermission ($permissionName);
/**
* Set `$permissionName` string with `$allow` boolean to allow
* or to disallow permission (with `$allow = FALSE`) for user or role.
* @param string $permissionName Strings describing what is allowed/disallowed to do for user or role.
* @param bool $allow `TRUE` by default.
* @return \MvcCore\Ext\Auths\Basics\Role
*/
public function SetPermission ($permissionName, $allow = TRUE);
/**
* Get array of strings describing what is allowed to do for user or role.
* @return \string[]
*/
public function & GetPermissions();
/**
* Set array of strings describing what is allowed to do for user or role.
* @param string|\string[] $permissions The permissions string, separated by comma character or array of strings.
* @return \MvcCore\Ext\Auths\Basics\Role
*/
public function SetPermissions ($permissions);
// trait: \MvcCore\Ext\Auths\Basics\Traits\Role
/**
* Get unique role name.
* Example: `"management" | "editor" | "quest"`
* @return string
*/
public function GetName ();
/**
* Set unique role name.
* Example: `"management" | "editor" | "quest"`
* @param string $name
* @return \MvcCore\Ext\Auths\Basics\Role
*/
public function SetName ($name);
/**
* Get `TRUE` if given permission string(s) is/are (all or some) allowed for user or user role.
* `FALSE` otherwise. Permission name could contain asterisk char `*` in any place.
* @param string|\string[] $permissionNameOrNames
* @param bool $allPermissionsRequired `TRUE` by default.
* @return bool
*/
public function IsAllowed ($permissionNameOrNames, $allPermissionsRequired = TRUE);
// class: \MvcCore\Ext\Auths\Basics\Role
/**
* Get role instance from application roles list. It could be database or any other custom resource.
* @param string $name Role unique name.
* @throws \RuntimeException
* @return \MvcCore\Ext\Auths\Basics\Role
*/
public function GetByName ($roleName);
}