Acl\Adapter\Utility\PhpAco::access PHP Method

access() public method

allow/deny ARO access to ARO
public access ( string $aro, string $aco, string $action, string $type = 'deny' ) : void
$aro string ARO string
$aco string ACO string
$action string Action string
$type string access type
return void
    public function access($aro, $aco, $action, $type = 'deny')
    {
        $aco = $this->resolve($aco);
        $depth = count($aco);
        $root = $this->_tree;
        $tree =& $root;
        foreach ($aco as $i => $node) {
            if (!isset($tree[$node])) {
                $tree[$node] = ['children' => []];
            }
            if ($i < $depth - 1) {
                $tree =& $tree[$node]['children'];
            } else {
                if (empty($tree[$node][$type])) {
                    $tree[$node][$type] = [];
                }
                $tree[$node][$type] = array_merge(is_array($aro) ? $aro : [$aro], $tree[$node][$type]);
            }
        }
        $this->_tree =& $root;
    }

Usage Example

Example #1
0
 /**
  * deny ARO access to ACO
  *
  * @param string $aro ARO The requesting object identifier.
  * @param string $aco ACO The controlled object identifier.
  * @param string $action Action (defaults to *)
  * @return bool Success
  */
 public function deny($aro, $aco, $action = "*")
 {
     return $this->Aco->access($this->Aro->resolve($aro), $aco, $action, 'deny');
 }