Hook to handle access authorization, without throw Exception.

@param string $action
@param object $object

@return bool
493400
public function hasAccess($action, $object = null)
    {
        $access = $this->getAccess();

        if (!\array_key_exists($action, $access)) {
            return false;
        }

        if (!\is_array($access[$action])) {
            $access[$action] = [$access[$action]];
        }

        foreach ($access[$action] as $role) {
            if (false === $this->isGranted($role, $object)) {
                return false;
            }
        }

        return true;
    }
1195747
public function accessPossible(User $user, $controller, $action) {
        $isUser = false;
        foreach ($user->getRoles() as $role) {
            if ($role == TaoRoles::BASE_USER) {
                $isUser = true;
                break;
            }
        }
        return $isUser || $this->inWhiteList($controller, $action);
    }
330469
public static function userHasPermissionForGroupAction($group, $action)
	{
		// Get user roles
		$roles = self::getGroupMemberRoles(
			\User::get('id'),
			$group->get('gidNumber')
		);

		// Check to see if any of our roles for user has permission for action
		foreach ($roles as $role)
		{
			$permissions = json_decode($role['permissions']);
			$permissions = (is_object($permissions)) ? $permissions : new \stdClass;
			if (property_exists($permissions, $action) && $permissions->$action == 1)
			{
				return true;
			}
		}
		return false;
	}
1247881
private function executeAction(string $action)
    {
        list($controller, $method) = explode('@', $action);

        $class = '\App\Controllers\\'.ucfirst($controller).'Controller';

        if (!class_exists($class)) {
            throw new ExceptionHandler('Class "'.$class.'" not found.');
        }

        $controllerInstantiate = new $class();

        if (!method_exists($controllerInstantiate, $method)) {
            throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.');
        }

        return call_user_func_array([new $controllerInstantiate, $method], []);
    }
1148725
public function setAction($action) {
        if (empty($action)) {
            throw new \Exception("Action cannot be empty", 0, null); //todo: create error code
        } else if (!is_string($action)) {
            throw new \Exception("Action must be a string", 0, null); //todo: create error code
        } else {
            $this->action = $action;
        }
    }
838829
public function canExecute($action)
    {
        if (
            $this->isOwnable() &&
            $this->actor &&
            $this->actor->authorize('access') === false
            ) {
            return false;
        }

        return parent::canExecute($action);
    }
307902
public function userAllowed($action)
    {
        if (user()->isAdmin()) {
            return true;
        }

        $this->_loadPermissions();
        $allowedRoles = $this->_permissions
            ->filter(function ($rule) use ($action) {
                return $rule->get('action') == $action;
            })
            ->extract('role_id')
            ->toArray();
        $intersect = array_intersect($allowedRoles, user()->get('role_ids'));

        return !empty($intersect);
    }
233361
public function canIf(string $action): bool
    {
        $roles = $this->getUserRoles();
        $action = Keyword::make($action);

        if (\is_null($this->actions->search($action))) {
            return false;
        }

        return $this->checkAuthorization($roles, $action);
    }
205834
protected function checkAllScheduledByAction(array $objects, $action): void
    {
        foreach ($objects as $object) {
            if (!$this->getAuthorizationChecker()->isGranted('perm_'.$action, $object)) {
                throw new AccessDeniedException('Insufficient privilege to '.$action.' the entity');
            }
        }
    }
762566
protected function can(string $action, ?Authorizable $user = null): bool
    {
        return ! \is_null($user)
                    ? $this->acl->canAs($user, $action)
                    : $this->acl->can($action);
    }
772563
public static function controller_for_object($object, $action = null)
    {
        $controller = $object->getControllerName();

        if ($action && class_exists($controller . '_' . ucfirst($action))) {
            $controller = $controller . '_' . ucfirst($action);
        }

        return Injector::inst()->create($controller, $object);
    }
293604
public function authorize(ActionDispatchEvent $event)
    {
        $callable = $event->getCallable();

        if (!$callable->isMethod() && !$callable->isMethodStatic()) {
            // Native function or \Closure
            return;
        }

        $class = $callable->getReflection()->getDeclaringClass()->getName();
        $method = $callable->getReflection()->getName();
        $parameters = $event->getParameters();
        $action = $event->getAction();

        foreach ($action->getSecurityGroups() as $group) {
            $authorized = $this->authorizationChecker
                ->isGrantedMethodCall($class, $method, $parameters, [], $group);

            if (!$authorized) {
                throw new AccessDeniedException();
            }
        }
    }
829953
protected function deleteWithAction($id, $action, $actionArg = null, $object = null, $class = null)
    {
        return $this->requestAction(RequestOps::DELETE, $action, $id, $actionArg, $object, $class);
    }
1135132
public function authorize(string $action, $value)
    {
        $permission = $this->getPermission($action);

        $result = $this->getManager()->getAgent()->can($permission);

        if (!$result) {
            return Collection::make([$this->newException(Tokens::NOT_AUTHORIZED, $permission)]);
        }

        return Collection::make();
    }
833935
protected function getPermissionInstance($resource, $context, $action) {
    $query = new ObjectQuery($this->permissionType, __CLASS__.__METHOD__);
    $tpl = $query->getObjectTemplate($this->permissionType);
    $tpl->setValue('resource', Criteria::asValue('=', $resource));
    $tpl->setValue('context', Criteria::asValue('=', $context));
    $tpl->setValue('action', Criteria::asValue('=', $action));
    $permissions = $query->execute(BuildDepth::SINGLE);
    return (sizeof($permissions) > 0) ? $permissions[0] : null;
  }
694492
protected function check_access($action = null)
	{
		is_null($action) and $action = $this->request->action;

		if ($this->has_access($action) === false)
		{
			$context = array(
				'form' => array(
					'%action%' => $action,
					'%items%'  => $this->get_name(999),
				)
			);

			\Logger::instance('alert')->error(gettext('You are not authorized to %action% %items%.'), $context);

			return \Response::redirect_back(\Uri::admin(false));
		}
	}
263233
public static function beforeActionAccess($event)
    {
        $controller = $event->sender;
        $permissionName = AuthItem::createPermissionName([$controller->module->id, $controller->id, $controller->action->id]);
        if (!AuthItem::checkAccess($permissionName, Yii::$app->user)) {
            throw new HttpException(403, Yii::t('modules/rbac', 'Access denied'));
        }
    }