protected function hasPermission(string $permission, bool $return = false)
    {
        $auth = $this->getContext()->getAuthentication();
        $user = $auth->getUser();
        $acl = $this->getContext()->getAccessControlList();

        if (!$acl->hasAccess($user, $permission)) {

            if ($return) {
                return false;
            }else{
                throw HttpException::forbidden('The current user has no permission to this action');
            }
        }

        return true;
    }
protected function hasPermission(string $permission, bool $return = false)
    {
        $auth = $this->getContext()->getAuthentication();
        $user = $auth->getUser();
        $acl = $this->getContext()->getAccessControlList();

        if (!$acl->hasAccess($user, $permission)) {

            if ($return) {
                return false;
            }else{
                throw HttpException::forbidden('The current user has no permission to this action');
            }
        }

        return true;
    }
protected function hasPermission ( string $ permission , bool $ return = false ) { $ auth = $ this -> getContext ( ) -> getAuthentication ( ) ; $ user = $ auth -> getUser ( ) ; $ acl = $ this -> getContext ( ) -> getAccessControlList ( ) ; if ( ! $ acl -> hasAccess ( $ user , $ permission ) ) { if ( $ return ) { return false ; } else { throw HttpException :: forbidden ( 'The current user has no permission to this action' ) ; } } return true ; }
Has the current user permission for the given action

@param string $permission
@param bool $return Return a boolean instead of throwing a forbidden exception
Has the current user permission for the given action