src/Sulu/Bundle/ContactBundle/Contact/AbstractContactManager.php
public function addNewContactRelations($contact, $data)
    {
        // urls
        $urls = $this->getProperty($data, 'urls');
        if (!empty($urls)) {
            foreach ($urls as $urlData) {
                $this->addUrl($contact, $urlData);
            }
            $this->setMainUrl($contact);
        }

        //faxes
        $faxes = $this->getProperty($data, 'faxes');
        if (!empty($faxes)) {
            foreach ($faxes as $faxData) {
                $this->addFax($contact, $faxData);
            }
            $this->setMainFax($contact);
        }

        // Social media profiles.
        $socialMediaProfiles = $this->getProperty($data, 'socialMediaProfiles');
        if (!empty($socialMediaProfiles)) {
            foreach ($socialMediaProfiles as $socialMediaProfileData) {
                $this->addSocialMediaProfile($contact, $socialMediaProfileData);
            }
        }

        // emails
        $emails = $this->getProperty($data, 'emails');
        if (!empty($emails)) {
            foreach ($emails as $emailData) {
                $this->addEmail($contact, $emailData);
            }
            $this->setMainEmail($contact);
        }

        // phones
        $phones = $this->getProperty($data, 'phones');
        if (!empty($phones)) {
            foreach ($phones as $phoneData) {
                $this->addPhone($contact, $phoneData);
            }
            $this->setMainPhone($contact);
        }

        // addresses
        $addresses = $this->getProperty($data, 'addresses');
        if (!empty($addresses)) {
            foreach ($addresses as $addressData) {
                $address = $this->createAddress($addressData, $isMain);
                $this->addAddress($contact, $address, $isMain);
            }
        }
        // set main address (if it was not set yet)
        $this->setMainForCollection($this->getAddressRelations($contact));

        // notes
        $notes = $this->getProperty($data, 'notes');
        if (!empty($notes)) {
            foreach ($notes as $noteData) {
                $this->addNote($contact, $noteData);
            }
        }

        // handle tags
        $tags = $this->getProperty($data, 'tags');
        if (!empty($tags)) {
            foreach ($tags as $tag) {
                $this->addTag($contact, $tag);
            }
        }

        // process details
        if (null !== $this->getProperty($data, 'bankAccounts')) {
            $this->processBankAccounts($contact, $this->getProperty($data, 'bankAccounts', []));
        }
    }
public function addNewContactRelations($contact, $data)
    {
        // urls
        $urls = $this->getProperty($data, 'urls');
        if (!empty($urls)) {
            foreach ($urls as $urlData) {
                $this->addUrl($contact, $urlData);
            }
            $this->setMainUrl($contact);
        }

        //faxes
        $faxes = $this->getProperty($data, 'faxes');
        if (!empty($faxes)) {
            foreach ($faxes as $faxData) {
                $this->addFax($contact, $faxData);
            }
            $this->setMainFax($contact);
        }

        // Social media profiles.
        $socialMediaProfiles = $this->getProperty($data, 'socialMediaProfiles');
        if (!empty($socialMediaProfiles)) {
            foreach ($socialMediaProfiles as $socialMediaProfileData) {
                $this->addSocialMediaProfile($contact, $socialMediaProfileData);
            }
        }

        // emails
        $emails = $this->getProperty($data, 'emails');
        if (!empty($emails)) {
            foreach ($emails as $emailData) {
                $this->addEmail($contact, $emailData);
            }
            $this->setMainEmail($contact);
        }

        // phones
        $phones = $this->getProperty($data, 'phones');
        if (!empty($phones)) {
            foreach ($phones as $phoneData) {
                $this->addPhone($contact, $phoneData);
            }
            $this->setMainPhone($contact);
        }

        // addresses
        $addresses = $this->getProperty($data, 'addresses');
        if (!empty($addresses)) {
            foreach ($addresses as $addressData) {
                $address = $this->createAddress($addressData, $isMain);
                $this->addAddress($contact, $address, $isMain);
            }
        }
        // set main address (if it was not set yet)
        $this->setMainForCollection($this->getAddressRelations($contact));

        // notes
        $notes = $this->getProperty($data, 'notes');
        if (!empty($notes)) {
            foreach ($notes as $noteData) {
                $this->addNote($contact, $noteData);
            }
        }

        // handle tags
        $tags = $this->getProperty($data, 'tags');
        if (!empty($tags)) {
            foreach ($tags as $tag) {
                $this->addTag($contact, $tag);
            }
        }

        // process details
        if (null !== $this->getProperty($data, 'bankAccounts')) {
            $this->processBankAccounts($contact, $this->getProperty($data, 'bankAccounts', []));
        }
    }
public function addNewContactRelations ( $ contact , $ data ) { // urls $ urls = $ this -> getProperty ( $ data , 'urls' ) ; if ( ! empty ( $ urls ) ) { foreach ( $ urls as $ urlData ) { $ this -> addUrl ( $ contact , $ urlData ) ; } $ this -> setMainUrl ( $ contact ) ; } //faxes $ faxes = $ this -> getProperty ( $ data , 'faxes' ) ; if ( ! empty ( $ faxes ) ) { foreach ( $ faxes as $ faxData ) { $ this -> addFax ( $ contact , $ faxData ) ; } $ this -> setMainFax ( $ contact ) ; } // Social media profiles. $ socialMediaProfiles = $ this -> getProperty ( $ data , 'socialMediaProfiles' ) ; if ( ! empty ( $ socialMediaProfiles ) ) { foreach ( $ socialMediaProfiles as $ socialMediaProfileData ) { $ this -> addSocialMediaProfile ( $ contact , $ socialMediaProfileData ) ; } } // emails $ emails = $ this -> getProperty ( $ data , 'emails' ) ; if ( ! empty ( $ emails ) ) { foreach ( $ emails as $ emailData ) { $ this -> addEmail ( $ contact , $ emailData ) ; } $ this -> setMainEmail ( $ contact ) ; } // phones $ phones = $ this -> getProperty ( $ data , 'phones' ) ; if ( ! empty ( $ phones ) ) { foreach ( $ phones as $ phoneData ) { $ this -> addPhone ( $ contact , $ phoneData ) ; } $ this -> setMainPhone ( $ contact ) ; } // addresses $ addresses = $ this -> getProperty ( $ data , 'addresses' ) ; if ( ! empty ( $ addresses ) ) { foreach ( $ addresses as $ addressData ) { $ address = $ this -> createAddress ( $ addressData , $ isMain ) ; $ this -> addAddress ( $ contact , $ address , $ isMain ) ; } } // set main address (if it was not set yet) $ this -> setMainForCollection ( $ this -> getAddressRelations ( $ contact ) ) ; // notes $ notes = $ this -> getProperty ( $ data , 'notes' ) ; if ( ! empty ( $ notes ) ) { foreach ( $ notes as $ noteData ) { $ this -> addNote ( $ contact , $ noteData ) ; } } // handle tags $ tags = $ this -> getProperty ( $ data , 'tags' ) ; if ( ! empty ( $ tags ) ) { foreach ( $ tags as $ tag ) { $ this -> addTag ( $ contact , $ tag ) ; } } // process details if ( null !== $ this -> getProperty ( $ data , 'bankAccounts' ) ) { $ this -> processBankAccounts ( $ contact , $ this -> getProperty ( $ data , 'bankAccounts' , [ ] ) ) ; } }
adds new relations.

@param Contact $contact
@param array $data
adds new relations .