[Security] Optimize RoleHierarchy's buildRoleMap method
This commit is contained in:
parent
b228378d1f
commit
c3b68b0d28
@ -65,9 +65,17 @@ class RoleHierarchy implements RoleHierarchyInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$visited[] = $role;
|
$visited[] = $role;
|
||||||
$this->map[$main] = array_unique(array_merge($this->map[$main], $this->hierarchy[$role]));
|
|
||||||
$additionalRoles = array_merge($additionalRoles, array_diff($this->hierarchy[$role], $visited));
|
foreach ($this->hierarchy[$role] as $roleToAdd) {
|
||||||
|
$this->map[$main][] = $roleToAdd;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (array_diff($this->hierarchy[$role], $visited) as $additionalRole) {
|
||||||
|
$additionalRoles[] = $additionalRole;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->map[$main] = array_unique($this->map[$main]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user