public function getEmailAddressOfContact(ContactInterface $contact, $useFallback = true)
    {
        // take contacts main-email
        $contactMainEmail = $contact->getMainEmail();
        if ($contact && $contactMainEmail) {
            return $contactMainEmail;
        }

        // fallback take contact's main-account main-email
        $account = $contact->getMainAccount();
        if ($useFallback && $account) {
            return $this->getEmailAddressOfAccount($account);
        }

        return null;
    }
public function getEmailAddressOfContact(ContactInterface $contact, $useFallback = true)
    {
        // take contacts main-email
        $contactMainEmail = $contact->getMainEmail();
        if ($contact && $contactMainEmail) {
            return $contactMainEmail;
        }

        // fallback take contact's main-account main-email
        $account = $contact->getMainAccount();
        if ($useFallback && $account) {
            return $this->getEmailAddressOfAccount($account);
        }

        return null;
    }
public function getEmailAddressOfContact ( ContactInterface $ contact , $ useFallback = true ) { // take contacts main-email $ contactMainEmail = $ contact -> getMainEmail ( ) ; if ( $ contact && $ contactMainEmail ) { return $ contactMainEmail ; } // fallback take contact's main-account main-email $ account = $ contact -> getMainAccount ( ) ; if ( $ useFallback && $ account ) { return $ this -> getEmailAddressOfAccount ( $ account ) ; } return null ; }
Gets email address of a contact

@param ContactInterface $contact
@param bool $useFallback

@return string|null
Gets email address of a contact