Rule
API reference › yii › rbac › Rule
Rule represents a business constraint that may be associated with a role, permission or assignment.
For more details and usage information on Rule, see the guide article on security authorization.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$createdAt | int | UNIX timestamp representing the rule creation time Default: null. | Rule |
$name | string | Name of the rule Default: null. | Rule |
$updatedAt | int | UNIX timestamp representing the rule updating time Default: null. | Rule |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__unset() | Sets an object property to null. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
execute() abstract | Executes the rule. | Rule |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
Method details
Section titled “Method details”execute()
Section titled “execute() ”abstract public function execute(string|int $user, yii\rbac\Item $item, array $params): boolExecutes the rule.
Parameters
| Parameter | Type | Description |
|---|---|---|
$user | string| | The user ID. This should be either an integer or a string representing the unique identifier of a user. See User::$id. |
$item | Item | The role or permission that this rule is associated with |
$params | array | Parameters passed to CheckAccessInterface::checkAccess(). |
Returns
bool: A value indicating whether the rule permits the auth item it is associated with.