protected function loadOrCreateUser($email)
    {
        $repository = $this->getUserRepository();
        $generator  = $this->getUserTokenGenerator();

        /* @var $user \Auth\Entity\User */
        $user = $repository->findByEmail(
            $email, /*do not check isDraft flag */
            null
        );

        if (!$user) {
            $user = $repository->create();
            $user->setEmail($email)
                 ->setLogin($email)
                 ->setRole(\Auth\Entity\User::ROLE_RECRUITER)
                 ->setIsDraft(true);
            $info = $user->getInfo();
            /* @var $info \Auth\Entity\InfoInterface */
            $info->setEmail($email);
        }

        $token = $generator->generate(
            $user, /* daysToLive */
            7
        ); // will store user!

        return array('user' => $user, 'token' => $token);
    }
protected function loadOrCreateUser($email)
    {
        $repository = $this->getUserRepository();
        $generator  = $this->getUserTokenGenerator();

        /* @var $user \Auth\Entity\User */
        $user = $repository->findByEmail(
            $email, /*do not check isDraft flag */
            null
        );

        if (!$user) {
            $user = $repository->create();
            $user->setEmail($email)
                 ->setLogin($email)
                 ->setRole(\Auth\Entity\User::ROLE_RECRUITER)
                 ->setIsDraft(true);
            $info = $user->getInfo();
            /* @var $info \Auth\Entity\InfoInterface */
            $info->setEmail($email);
        }

        $token = $generator->generate(
            $user, /* daysToLive */
            7
        ); // will store user!

        return array('user' => $user, 'token' => $token);
    }
protected function loadOrCreateUser ( $ email ) { $ repository = $ this -> getUserRepository ( ) ; $ generator = $ this -> getUserTokenGenerator ( ) ; /* @var $user \Auth\Entity\User */ $ user = $ repository -> findByEmail ( $ email , /*do not check isDraft flag */ null ) ; if ( ! $ user ) { $ user = $ repository -> create ( ) ; $ user -> setEmail ( $ email ) -> setLogin ( $ email ) -> setRole ( \ Auth \ Entity \ User :: ROLE_RECRUITER ) -> setIsDraft ( true ) ; $ info = $ user -> getInfo ( ) ; /* @var $info \Auth\Entity\InfoInterface */ $ info -> setEmail ( $ email ) ; } $ token = $ generator -> generate ( $ user , /* daysToLive */ 7 ) ; // will store user! return array ( 'user' => $ user , 'token' => $ token ) ; }
Loads or creates an user.

Tries to load an user from the database, and creates a new
user draft, if no user was found.
A token will be generated to authenticate this user in further interactions
(with other parts of this application).

@param string $email

@return array An array with the keys 'user' and 'token', where 'user' is an UserInterface instance and
'token' is the generated token.
Loads or creates an user .