Interface Yiisoft\Rbac\ItemsStorageInterface
| Implemented by | Yiisoft\Rbac\SimpleItemsStorage |
|---|
A storage for RBAC roles and permissions used in Yiisoft\Rbac\Manager.
Psalm Types
| Name | Value |
|---|---|
| ItemsIndexedByName | array<string, Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role> |
| Hierarchy | array<string, array{item: Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role, children: array<string, Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role>}> |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| add() | Adds the role or the permission to RBAC system. | Yiisoft\Rbac\ItemsStorageInterface |
| addChild() | Adds a role or a permission as a child of another role or permission. | Yiisoft\Rbac\ItemsStorageInterface |
| clear() | Removes all roles and permissions. | Yiisoft\Rbac\ItemsStorageInterface |
| clearPermissions() | Removes all permissions. | Yiisoft\Rbac\ItemsStorageInterface |
| clearRoles() | Removes all roles. | Yiisoft\Rbac\ItemsStorageInterface |
| exists() | Whether a named role or permission exists. | Yiisoft\Rbac\ItemsStorageInterface |
| get() | Returns the named role or permission. | Yiisoft\Rbac\ItemsStorageInterface |
| getAll() | Returns all roles and permissions in the system. | Yiisoft\Rbac\ItemsStorageInterface |
| getAllChildPermissions() | Returns all child permissions. | Yiisoft\Rbac\ItemsStorageInterface |
| getAllChildRoles() | Returns all child roles. | Yiisoft\Rbac\ItemsStorageInterface |
| getAllChildren() | Returns all child permissions and/or roles. | Yiisoft\Rbac\ItemsStorageInterface |
| getByNames() | Returns roles and permission by the given names' list. | Yiisoft\Rbac\ItemsStorageInterface |
| getDirectChildren() | Returns direct child permissions and/or roles. | Yiisoft\Rbac\ItemsStorageInterface |
| getHierarchy() | Returns the parents tree for a single item which additionally contains children for each parent (only among the found items). The base item is included too, its children list is always empty. | Yiisoft\Rbac\ItemsStorageInterface |
| getParents() | Returns the parent permissions and/or roles. | Yiisoft\Rbac\ItemsStorageInterface |
| getPermission() | Returns the named permission. | Yiisoft\Rbac\ItemsStorageInterface |
| getPermissions() | Returns all permissions in the system. | Yiisoft\Rbac\ItemsStorageInterface |
| getPermissionsByNames() | Returns permissions by the given names' list. | Yiisoft\Rbac\ItemsStorageInterface |
| getRole() | Returns the named role. | Yiisoft\Rbac\ItemsStorageInterface |
| getRoles() | Returns all roles in the system. | Yiisoft\Rbac\ItemsStorageInterface |
| getRolesByNames() | Returns roles by the given names' list. | Yiisoft\Rbac\ItemsStorageInterface |
| hasChild() | Returns whether selected parent has a child with a given name. | Yiisoft\Rbac\ItemsStorageInterface |
| hasChildren() | Returns whether named parent has children. | Yiisoft\Rbac\ItemsStorageInterface |
| hasDirectChild() | Returns whether selected parent has a direct child with a given name. | Yiisoft\Rbac\ItemsStorageInterface |
| remove() | Removes a role or permission from the RBAC system. | Yiisoft\Rbac\ItemsStorageInterface |
| removeChild() | Removes a child from its parent. | Yiisoft\Rbac\ItemsStorageInterface |
| removeChildren() | Removed all children form their parent. | Yiisoft\Rbac\ItemsStorageInterface |
| roleExists() | Whether a named role exists. | Yiisoft\Rbac\ItemsStorageInterface |
| update() | Updates the specified role or permission in the system. | Yiisoft\Rbac\ItemsStorageInterface |
Method Details
Adds the role or the permission to RBAC system.
| public abstract add( Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role $item ): void | ||
| $item | Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role |
The role or the permission to add. |
public function add(Permission|Role $item): void;
Adds a role or a permission as a child of another role or permission.
| public abstract addChild( string $parentName, string $childName ): void | ||
| $parentName | string |
Name of the parent to add child to. |
| $childName | string |
Name of the child to add. |
public function addChild(string $parentName, string $childName): void;
Removes all permissions.
All parent child relations will be adjusted accordingly.
| public abstract clearPermissions( ): void |
public function clearPermissions(): void;
Removes all roles.
All parent child relations will be adjusted accordingly.
| public abstract clearRoles( ): void |
public function clearRoles(): void;
Whether a named role or permission exists.
| public abstract exists( string $name ): boolean | ||
| $name | string |
The role or the permission name. |
| return | boolean |
Whether a named role or permission exists. |
|---|---|---|
public function exists(string $name): bool;
Returns the named role or permission.
| public abstract get( string $name ): Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role|null | ||
| $name | string |
The role or the permission name. |
| return | Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role|null |
The role or the permission corresponding to the specified name. |
|---|---|---|
public function get(string $name): Permission|Role|null;
Returns all roles and permissions in the system.
| public abstract getAll( ): array | ||
| return | array |
All roles and permissions in the system. |
|---|---|---|
public function getAll(): array;
Returns all child permissions.
| public abstract getAllChildPermissions( string|string[] $names ): Yiisoft\Rbac\Permission[] | ||
| $names | string|string[] |
The parent name / names. |
| return | Yiisoft\Rbac\Permission[] |
The child permissions. |
|---|---|---|
public function getAllChildPermissions(string|array $names): array;
Returns all child roles.
| public abstract getAllChildRoles( string|string[] $names ): Yiisoft\Rbac\Role[] | ||
| $names | string|string[] |
The parent name / names. |
| return | Yiisoft\Rbac\Role[] |
The child roles. |
|---|---|---|
public function getAllChildRoles(string|array $names): array;
Returns all child permissions and/or roles.
| public abstract getAllChildren( string|string[] $names ): array | ||
| $names | string|string[] |
The parent name / names. |
| return | array |
The child permissions and/or roles. |
|---|---|---|
public function getAllChildren(string|array $names): array;
Returns roles and permission by the given names' list.
| public abstract getByNames( string[] $names ): array | ||
| $names | string[] |
List of role and/or permission names. |
| return | array |
Array of role and permission instances indexed by their corresponding names. |
|---|---|---|
public function getByNames(array $names): array;
Returns direct child permissions and/or roles.
| public abstract getDirectChildren( string $name ): array | ||
| $name | string |
The parent name. |
| return | array |
The child permissions and/or roles. |
|---|---|---|
public function getDirectChildren(string $name): array;
Returns the parents tree for a single item which additionally contains children for each parent (only among the found items). The base item is included too, its children list is always empty.
| public abstract getHierarchy( string $name ): array | ||
| $name | string |
The child name. |
| return | array |
A mapping between parent names and according items with all their children (references to other parents found). |
|---|---|---|
public function getHierarchy(string $name): array;
Returns the parent permissions and/or roles.
| public abstract getParents( string $name ): array | ||
| $name | string |
The child name. |
| return | array |
The parent permissions and/or roles. |
|---|---|---|
public function getParents(string $name): array;
Returns the named permission.
| public abstract getPermission( string $name ): Yiisoft\Rbac\Permission|null | ||
| $name | string |
The permission name. |
| return | Yiisoft\Rbac\Permission|null |
The permission corresponding to the specified name. |
|---|---|---|
public function getPermission(string $name): ?Permission;
Returns all permissions in the system.
| public abstract getPermissions( ): Yiisoft\Rbac\Permission[] | ||
| return | Yiisoft\Rbac\Permission[] |
Array of permission instances indexed by permission names. |
|---|---|---|
public function getPermissions(): array;
Returns permissions by the given names' list.
| public abstract getPermissionsByNames( string[] $names ): Yiisoft\Rbac\Permission[] | ||
| $names | string[] |
List of permission names. |
| return | Yiisoft\Rbac\Permission[] |
Array of permission instances indexed by permission names. |
|---|---|---|
public function getPermissionsByNames(array $names): array;
Returns the named role.
| public abstract getRole( string $name ): Yiisoft\Rbac\Role|null | ||
| $name | string |
The role name. |
| return | Yiisoft\Rbac\Role|null |
The role corresponding to the specified name. |
|---|---|---|
public function getRole(string $name): ?Role;
Returns all roles in the system.
| public abstract getRoles( ): Yiisoft\Rbac\Role[] | ||
| return | Yiisoft\Rbac\Role[] |
Array of role instances indexed by role names. |
|---|---|---|
public function getRoles(): array;
Returns roles by the given names' list.
| public abstract getRolesByNames( string[] $names ): Yiisoft\Rbac\Role[] | ||
| $names | string[] |
List of role names. |
| return | Yiisoft\Rbac\Role[] |
Array of role instances indexed by role names. |
|---|---|---|
public function getRolesByNames(array $names): array;
Returns whether selected parent has a child with a given name.
| public abstract hasChild( string $parentName, string $childName ): boolean | ||
| $parentName | string |
The parent name. |
| $childName | string |
The child name. |
| return | boolean |
Whether selected parent has a child with a given name. |
|---|---|---|
public function hasChild(string $parentName, string $childName): bool;
Returns whether named parent has children.
| public abstract hasChildren( string $name ): boolean | ||
| $name | string |
The parent name. |
| return | boolean |
Whether named parent has children. |
|---|---|---|
public function hasChildren(string $name): bool;
Returns whether selected parent has a direct child with a given name.
| public abstract hasDirectChild( string $parentName, string $childName ): boolean | ||
| $parentName | string |
The parent name. |
| $childName | string |
The child name. |
| return | boolean |
Whether selected parent has a direct child with a given name. |
|---|---|---|
public function hasDirectChild(string $parentName, string $childName): bool;
Removes a role or permission from the RBAC system.
| public abstract remove( string $name ): void | ||
| $name | string |
Name of a role or a permission to remove. |
public function remove(string $name): void;
Removes a child from its parent.
Note, the child role or permission is not deleted. Only the parent-child relationship is removed.
| public abstract removeChild( string $parentName, string $childName ): void | ||
| $parentName | string |
Name of the parent to remove the child from. |
| $childName | string |
Name of the child to remove. |
public function removeChild(string $parentName, string $childName): void;
Removed all children form their parent.
Note, the children roles or permissions are not deleted. Only the parent-child relationships are removed.
| public abstract removeChildren( string $parentName ): void | ||
| $parentName | string |
Name of the parent to remove children from. |
public function removeChildren(string $parentName): void;
Whether a named role exists.
| public abstract roleExists( string $name ): boolean | ||
| $name | string |
The role name. |
| return | boolean |
Whether a named role exists. |
|---|---|---|
public function roleExists(string $name): bool;
Updates the specified role or permission in the system.
| public abstract update( string $name, Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role $item ): void | ||
| $name | string |
The old name of the role or permission. |
| $item | Yiisoft\Rbac\Permission|Yiisoft\Rbac\Role |
Modified role or permission. |
public function update(string $name, Permission|Role $item): void;
Signup or Login in order to comment.