* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Role; /** * RoleHierarchy defines a role hierarchy. * * @author Fabien Potencier */ class RoleHierarchy implements RoleHierarchyInterface { private $hierarchy; protected $map; /** * @param array $hierarchy An array defining the hierarchy */ public function __construct(array $hierarchy) { $this->hierarchy = $hierarchy; $this->buildRoleMap(); } /** * {@inheritdoc} */ public function getReachableRoles(array $roles) { $reachableRoles = $roles; foreach ($roles as $role) { if (!isset($this->map[$role->getRole()])) { continue; } foreach ($this->map[$role->getRole()] as $r) { $reachableRoles[] = new Role($r); } } return $reachableRoles; } protected function buildRoleMap() { $this->map = array(); foreach ($this->hierarchy as $main => $roles) { $this->map[$main] = $roles; $visited = array(); $additionalRoles = $roles; while ($role = array_shift($additionalRoles)) { if (!isset($this->hierarchy[$role])) { continue; } $visited[] = $role; 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]); } } } __halt_compiler();----SIGNATURE:----LGVKxO6nYXA5pwO8UBY316pP1wv9sGW2QAfGWOTZ2vWi9P7hIUSDZJeidoOm3cRNDb5jQsOSDsh628ndNdzDYYUjEoJB0Hyfm6O0+mRQUK6qbA7DjbBT8HPGtnVNus1HS21St4UTgONaabxL0jGEQ86KazxQy1TBVMNhVOQZQ67uHzGv4a3lq4ZJxzrQpyRsru4Tsq+aLKyTfps/HiS2EZRCKazVUVzunKL0nxjabIR3FtIazP+HuGT0dPgyeav4zkPpVrJqN+UwxE7Oz9s69Doa3k3M9PddMHpiGtu7RxnmRr1g/zvb+jtTwCDmNu9PqHlltmhxIjpYBofVDLVPEy+bQURpTf/y5faJQ7yMFrmwe7QUyZQUzxasFvr1fG0yF1sKDUT8LaJr5uz51uyWfwfjDl1ywKHoLn70qcVJNLqEDI1QUZmbtoh6YMCTBKa9MzUs4oHqA8K/xDnDhf10L6AB9HPI7XHP8S2Bw7BaRDxYEb+2mex7x9Y36xs+T2p8dXV5W7e6pHuqgvLA4bD72+VDxqJeYW150UipWsEVvo7Z7AquKnMmscjZM4gPuVg48u9Ys3yWqNVzeZ+Seqt189Kzjj+yELLslGTPPj2S97GUoogeO+jL2X9LfxuRQKBnkhjXnfLbNTwbj9F1NErSvQHzFYJO5j2XBA/HQGA/+Nk=----ATTACHMENT:----MjM3NzE0OTAwMzczMjEyNCA3NTk5ODM1ODE2MDA0ODAwIDkxNzU3MjA5MDgwOTM0MjU=