Acl\Model\Table\PermissionsTable::allow PHP Method

allow() public method

Allow $aro to have access to action $actions in $aco
public allow ( string $aro, string $aco, string $actions = '*', integer $value = 1 ) : boolean
$aro string ARO The requesting object identifier.
$aco string ACO The controlled object identifier.
$actions string Action (defaults to *) Invalid permissions will result in an exception
$value integer Value to indicate access type (1 to give access, -1 to deny, 0 to inherit)
return boolean Success
    public function allow($aro, $aco, $actions = '*', $value = 1)
    {
        $perms = $this->getAclLink($aro, $aco);
        $permKeys = $this->getAcoKeys($this->schema()->columns());
        $alias = $this->alias();
        $save = [];
        if (!$perms) {
            trigger_error(__d('cake_dev', '{0} - Invalid node', ['DbAcl::allow()']), E_USER_WARNING);
            return false;
        }
        if (isset($perms[0])) {
            $save = $perms[0][$alias];
        }
        if ($actions === '*') {
            $save = array_combine($permKeys, array_pad([], count($permKeys), $value));
        } else {
            if (!is_array($actions)) {
                if ($actions[0] !== '_') {
                    $actions = ['_' . $actions];
                } else {
                    $actions = [$actions];
                }
            }
            foreach ($actions as $action) {
                if ($action[0] !== '_') {
                    $action = '_' . $action;
                }
                if (!in_array($action, $permKeys, true)) {
                    throw new Exception(__d('cake_dev', 'Invalid permission key "{0}"', [$action]));
                }
                $save[$action] = $value;
            }
        }
        list($save['aro_id'], $save['aco_id']) = [$perms['aro'], $perms['aco']];
        if ($perms['link'] && !empty($perms['link'][$alias])) {
            $save['id'] = $perms['link'][$alias][0]['id'];
        } else {
            unset($save['id']);
            $this->id = null;
        }
        $entityClass = $this->entityClass();
        $entity = new $entityClass($save);
        return $this->save($entity) !== false;
    }