/** * Denies the access of the user. * The default implementation will redirect the user to the login page if he is a guest; * if the user is already logged, a 403 HTTP exception will be thrown. * * @param User $user the current user * @throws ForbiddenHttpException if the user is already logged in. */ protected function denyAccess($user) { if ($user->getIsGuest()) { $user->loginRequired(); } else { throw new ForbiddenHttpException(Leaps::t('leaps', 'You are not allowed to perform this action.')); } }
/** * @param User $user the user object * @return boolean whether the rule applies to the role */ protected function matchRole($user) { if (empty($this->roles)) { return true; } foreach ($this->roles as $role) { if ($role === '?') { if ($user->getIsGuest()) { return true; } } elseif ($role === '@') { if (!$user->getIsGuest()) { return true; } } elseif ($user->can($role)) { return true; } } return false; }