src/Sulu/Bundle/SecurityBundle/UserManager/UserManager.php
private function processEmail(UserInterface $user, $email, $contact = null)
    {
        if ($contact) {
            // if no email passed try to use the contact's first email
            if (null === $email &&
                array_key_exists('emails', $contact) && count($contact['emails']) > 0 &&
                $this->isEmailUnique($contact['emails'][0]['email'])
            ) {
                $email = $contact['emails'][0]['email'];
            }
            if (null !== $email) {
                if (!$this->isEmailUnique($email)) {
                    throw new EmailNotUniqueException($email);
                }
                $user->setEmail($email);
            }
        } else {
            if (null !== $email) {
                if ($email !== $user->getEmail() &&
                    !$this->isEmailUnique($email)
                ) {
                    throw new EmailNotUniqueException($email);
                }
                $user->setEmail($email);
            } else {
                $user->setEmail(null);
            }
        }
    }
private function processEmail(UserInterface $user, $email, $contact = null)
    {
        if ($contact) {
            // if no email passed try to use the contact's first email
            if (null === $email &&
                array_key_exists('emails', $contact) && count($contact['emails']) > 0 &&
                $this->isEmailUnique($contact['emails'][0]['email'])
            ) {
                $email = $contact['emails'][0]['email'];
            }
            if (null !== $email) {
                if (!$this->isEmailUnique($email)) {
                    throw new EmailNotUniqueException($email);
                }
                $user->setEmail($email);
            }
        } else {
            if (null !== $email) {
                if ($email !== $user->getEmail() &&
                    !$this->isEmailUnique($email)
                ) {
                    throw new EmailNotUniqueException($email);
                }
                $user->setEmail($email);
            } else {
                $user->setEmail(null);
            }
        }
    }
private function processEmail ( UserInterface $ user , $ email , $ contact = null ) { if ( $ contact ) { // if no email passed try to use the contact's first email if ( null === $ email && array_key_exists ( 'emails' , $ contact ) && count ( $ contact [ 'emails' ] ) > 0 && $ this -> isEmailUnique ( $ contact [ 'emails' ] [ 0 ] [ 'email' ] ) ) { $ email = $ contact [ 'emails' ] [ 0 ] [ 'email' ] ; } if ( null !== $ email ) { if ( ! $ this -> isEmailUnique ( $ email ) ) { throw new EmailNotUniqueException ( $ email ) ; } $ user -> setEmail ( $ email ) ; } } else { if ( null !== $ email ) { if ( $ email !== $ user -> getEmail ( ) && ! $ this -> isEmailUnique ( $ email ) ) { throw new EmailNotUniqueException ( $ email ) ; } $ user -> setEmail ( $ email ) ; } else { $ user -> setEmail ( null ) ; } } }
Processes the email and adds it to the user.

@param UserInterface $user
@param string $email
@param null|array $contact

@throws EmailNotUniqueException
Processes the email and adds it to the user .