roles() public method

From the perspective of the given ARO, walk down the tree and collect all inherited AROs levelwise such that AROs from different branches with equal distance to the requested ARO will be collected at the same index. The resulting array will contain a prioritized list of (list of) roles ordered from the most distant AROs to the requested one itself.
public roles ( string | array $aro ) : array
$aro string | array An ARO identifier
return array prioritized AROs
Example #1
0
 /**
  * Main ACL check function. Checks to see if the ARO (access request object) has access to the
  * ACO (access control object).
  *
  * @param string $aro ARO
  * @param string $aco ACO
  * @param string $action Action
  * @return bool true if access is granted, false otherwise
  */
 public function check($aro, $aco, $action = "*")
 {
     $allow = $this->options['policy'];
     $prioritizedAros = $this->Aro->roles($aro);
     if ($action && $action !== "*") {
         $aco .= '/' . $action;
     }
     $path = $this->Aco->path($aco);
     if (empty($path)) {
         return $allow;
     }
     foreach ($path as $node) {
         foreach ($prioritizedAros as $aros) {
             if (!empty($node['allow'])) {
                 $allow = $allow || count(array_intersect($node['allow'], $aros));
             }
             if (!empty($node['deny'])) {
                 $allow = $allow && !count(array_intersect($node['deny'], $aros));
             }
         }
     }
     return $allow;
 }