public function userHasAccess(User $user)
    {
        if ($this->getWhitelisted() === false) {
            return true;
        }

        $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('user', $user))
                ->setMaxResults(1);

        $serverUsers = $this->users->matching($criteria);
        if ($serverUsers->count() === 0) {
            return false;
        }

        $serverUser = $serverUsers->first();

        if ($serverUser->getBanned() === true) {
            return false;
        }

        if ($this->getRequiresApproval() === true && $serverUser->getApproved() === false) {
            return false;
        }

        return true;
    }
public function userHasAccess(User $user)
    {
        if ($this->getWhitelisted() === false) {
            return true;
        }

        $criteria = Criteria::create()
                ->where(Criteria::expr()->eq('user', $user))
                ->setMaxResults(1);

        $serverUsers = $this->users->matching($criteria);
        if ($serverUsers->count() === 0) {
            return false;
        }

        $serverUser = $serverUsers->first();

        if ($serverUser->getBanned() === true) {
            return false;
        }

        if ($this->getRequiresApproval() === true && $serverUser->getApproved() === false) {
            return false;
        }

        return true;
    }
public function userHasAccess ( User $ user ) { if ( $ this -> getWhitelisted ( ) === false ) { return true ; } $ criteria = Criteria :: create ( ) -> where ( Criteria :: expr ( ) -> eq ( 'user' , $ user ) ) -> setMaxResults ( 1 ) ; $ serverUsers = $ this -> users -> matching ( $ criteria ) ; if ( $ serverUsers -> count ( ) === 0 ) { return false ; } $ serverUser = $ serverUsers -> first ( ) ; if ( $ serverUser -> getBanned ( ) === true ) { return false ; } if ( $ this -> getRequiresApproval ( ) === true && $ serverUser -> getApproved ( ) === false ) { return false ; } return true ; }
Get whether the user has access

@return boolean
Get whether the user has access