protected function hasRolesOrRedirect(array $roles, $or, $redirectUrl, $originUrl = "") {

        $user = $this->getKernelEventListener()->getUser();

        if (false === UserHelper::hasRoles($user, $roles, $or)) {

            // Throw a bad user role exception with an anonymous user if user is null.
            $user = null !== $user ? $user : new User("anonymous", "");
            throw new BadUserRoleException($user, $roles, $redirectUrl, $originUrl);
        }

        return true;
    }
protected function hasRolesOrRedirect(array $roles, $or, $redirectUrl, $originUrl = "") {

        $user = $this->getKernelEventListener()->getUser();

        if (false === UserHelper::hasRoles($user, $roles, $or)) {

            // Throw a bad user role exception with an anonymous user if user is null.
            $user = null !== $user ? $user : new User("anonymous", "");
            throw new BadUserRoleException($user, $roles, $redirectUrl, $originUrl);
        }

        return true;
    }
protected function hasRolesOrRedirect ( array $ roles , $ or , $ redirectUrl , $ originUrl = "" ) { $ user = $ this -> getKernelEventListener ( ) -> getUser ( ) ; if ( false === UserHelper :: hasRoles ( $ user , $ roles , $ or ) ) { // Throw a bad user role exception with an anonymous user if user is null. $ user = null !== $ user ? $ user : new User ( "anonymous" , "" ) ; throw new BadUserRoleException ( $ user , $ roles , $ redirectUrl , $ originUrl ) ; } return true ; }
Determines if the connected user have roles or redirect.

@param array $roles The roles.
@param bool $or OR ?
@param string $redirectUrl The redirect URL.
@param string $originUrl The origin URL.
@return bool Returns true.
@throws BadUserRoleException Throws a bad user role exception.
Determines if the connected user have roles or redirect .