-
-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathRoleManager.php
More file actions
46 lines (40 loc) · 1.15 KB
/
RoleManager.php
File metadata and controls
46 lines (40 loc) · 1.15 KB
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
<?php
declare(strict_types=1);
namespace Casbin\Rbac\DefaultRoleManager;
use Casbin\Log\Logger\DefaultLogger;
use Casbin\Rbac\DefaultRoleManager\Traits\RoleManager as RoleManagerTrait;
use Casbin\Rbac\RoleManager as RoleManagerContract;
use Closure;
/**
* Class RoleManager.
* Provides a default implementation for the RoleManager interface.
*
* @author techlee@qq.com
* @author 1692898084@qq.com
*/
class RoleManager implements RoleManagerContract
{
use RoleManagerTrait;
/**
* RoleManager constructor.
*
* @param int $maxHierarchyLevel
* @param Closure|null $matchingFunc
*/
public function __construct(int $maxHierarchyLevel, ?Closure $matchingFunc = null)
{
$this->clear();
$this->maxHierarchyLevel = $maxHierarchyLevel;
$this->matchingFunc = $matchingFunc;
$this->setLogger(new DefaultLogger());
}
/**
* @param RoleManager $roleManager
*/
public function copyFrom(RoleManager &$roleManager): void
{
$this->rangeLinks($roleManager->allRoles, function ($name1, $name2, $domain) {
$this->addLink($name1, $name2, $domain);
});
}
}