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;
}