39 public static function addRole(
string $name, ?array $parents = []): void {
43 public static function addRoles(array $nameParents): void {
44 foreach ($nameParents as $name => $parents) {
45 self::$aclList->addRole(
new Role($name, $parents));
49 public static function addResource(
string $name, ?
string $value =
null): void {
50 self::$aclList->addResource(new
Resource($name, $value));
54 foreach ($nameValue as $name => $value) {
55 self::$aclList->addResource(
new Resource($name, $value));
59 public static function addPermission(
string $name,
int $level = 0): void {
60 self::$aclList->addPermission(new
Permission($name, $level));
64 foreach ($nameLevel as $name => $level) {
65 self::$aclList->addPermission(
new Permission($name, $level));
70 self::$aclList->setPermissionLevel($name, $level);
74 return self::$aclList->getRoles();
78 return self::$aclList->getResources();
90 return self::$aclList->getPermissions();
94 return self::$aclList->getAcls();
104 public static function allow(
string $role, ?
string $resource =
'*', ?
string $permission =
'ALL'): void {
105 self::$aclList->allow($role, $resource ??
'*', $permission ??
'ALL');
115 public static function addAndAllow(
string $role, ?
string $resource =
'*', ?
string $permission =
'ALL'): void {
116 self::$aclList->addAndAllow($role, $resource ??
'*', $permission ??
'ALL');
127 public static function isAllowed(
string $role, ?
string $resource =
'*', ?
string $permission =
'ALL'): bool {
128 return self::$aclList->isAllowed($role, $resource ??
'*', $permission ??
'ALL');
132 $routeInfo=
Router::getRouteInfoByName($routeName);
133 if (!isset ( $routeInfo [
'controller'] )) {
134 $routeInfo=\current($routeInfo);
136 $controller=$routeInfo[
'controller']??
null;
137 $action=$routeInfo[
'action']??
null;
138 if(isset($controller) && isset($action)){
139 $resourceController = self::getPermissionMap ()->getRessourcePermission ( $controller, $action );
140 if (isset ( $resourceController )) {
142 if (self::isAllowed ( $role, $resourceController [
'resource'], $resourceController [
'permission'] )) {
146 catch(AclException $e){
159 self::$aclList->saveAll();
167 self::$aclList->removeRole($role);
175 self::$aclList->removePermission($permission);
183 self::$aclList->removeResource($resource);
192 public static function removeAcl(
string $role,
string $resource, ?
string $permission =
null): void {
193 self::$aclList->removeAcl($role, $resource, $permission);
201 if (! isset(self::$permissionMap)) {
203 self::$permissionMap->load();
205 return self::$permissionMap;
215 public static function associate(
string $controller,
string $action,
string $resource,
string $permission =
'ALL'):void {
216 self::$aclList->getResourceByName($resource);
217 self::$aclList->getPermissionByName($permission);
218 self::$permissionMap->addAction($controller, $action, $resource, $permission);
Manager for caches (Router, Rest, models).
Manipulates class and namespace names Ubiquity\cache$ClassUtils This class is part of Ubiquity.
Ubiquity\exceptions$AclException This class is part of Ubiquity.
Ubiquity\security\acl$AclManager This class is part of Ubiquity.
static removeAcl(string $role, string $resource, ?string $permission=null)
static saveAll()
Save all acls,roles, resources and permissions for AclProviders with no autoSave.
static addRoles(array $nameParents)
static removePermission(string $permission)
static array $providersPersistence
static isAllowed(string $role, ?string $resource=' *', ?string $permission='ALL')
Check if access to resource is allowed for role with the permission.
static isAllowedRoute(string $role, string $routeName)
static getPermissionMap()
static allow(string $role, ?string $resource=' *', ?string $permission='ALL')
Allow role to access to resource with the permission.
static addAndAllow(string $role, ?string $resource=' *', ?string $permission='ALL')
Add role, resource and permission and allow this role to access to resource with the permission.
static removeRole(string $role)
static removeResource(string $resource)
static addResources(array $nameValue)
static addRole(string $name, ?array $parents=[])
static addPermission(string $name, int $level=0)
static associate(string $controller, string $action, string $resource, string $permission='ALL')
static addPermissions(array $nameLevel)
static setPermissionLevel(string $name, int $level)
static addResource(string $name, ?string $value=null)
static PermissionsMap $permissionMap
Ubiquity\security\acl\cache$AclControllerParser This class is part of Ubiquity.
Ubiquity\security\acl\cache$PermissionsMap This class is part of Ubiquity.
Ubiquity\security\acl\models$AbastractAclElement This class is part of Ubiquity.
Ubiquity\security\acl\models$AclElement This class is part of Ubiquity.
Ubiquity\security\acl\models$AclList This class is part of Ubiquity.
Ubiquity\security\acl\models$Permission This class is part of Ubiquity.
Ubiquity\security\acl\models$Resource This class is part of Ubiquity.
Ubiquity\security\acl\models$Role This class is part of Ubiquity.
Ubiquity\security\acl\persistence$AclCacheProvider This class is part of Ubiquity.
Load and save Acls with a database using DAO.
Ubiquity\security\acl\persistence$AclProviderInterface This class is part of Ubiquity.