src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php
public function findUserByUsername($username)
    {
        $qb = $this->createQueryBuilder('user')
            ->where('user.username=:username');

        $query = $qb->getQuery();
        $query->setParameter('username', $username);

        return $query->getSingleResult();
    }
public function findUserByUsername($username)
    {
        $qb = $this->createQueryBuilder('user')
            ->where('user.username=:username');

        $query = $qb->getQuery();
        $query->setParameter('username', $username);

        return $query->getSingleResult();
    }
public function findUserByUsername ( $ username ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> where ( 'user.username=:username' ) ; $ query = $ qb -> getQuery ( ) ; $ query -> setParameter ( 'username' , $ username ) ; return $ query -> getSingleResult ( ) ; }
Finds a user for the given username.

This method throws UsernameNotFoundException if the user is not found.

@param string $username The username

@return UserInterface

@throws NoResultException if the user is not found
Finds a user for the given username .