src/Sulu/Bundle/ContactBundle/Contact/AbstractContactManager.php
public function processAddresses($contact, $addresses)
    {
        $getAddressId = function($addressRelation) {
            return $addressRelation->getAddress()->getId();
        };

        $delete = function($addressRelation) use ($contact) {
            $this->removeAddressRelation($contact, $addressRelation);

            return true;
        };

        $update = function($addressRelation, $matchedEntry) use ($contact) {
            $address = $addressRelation->getAddress();
            $result = $this->updateAddress($address, $matchedEntry, $isMain);
            if ($isMain) {
                $this->unsetMain($this->getAddressRelations($contact));
            }
            $addressRelation->setMain($isMain);

            return $result;
        };

        $add = function($addressData) use ($contact) {
            $address = $this->createAddress($addressData, $isMain);
            $this->addAddress($contact, $address, $isMain);

            return true;
        };

        $entities = $this->getAddressRelations($contact);

        $result = $this->processSubEntities(
            $entities,
            $addresses,
            $getAddressId,
            $add,
            $update,
            $delete
        );

        $this->resetIndexOfSubentites($entities);

        // check if main exists, else take first address
        $this->checkAndSetMainAddress($this->getAddressRelations($contact));

        return $result;
    }
public function processAddresses($contact, $addresses)
    {
        $getAddressId = function($addressRelation) {
            return $addressRelation->getAddress()->getId();
        };

        $delete = function($addressRelation) use ($contact) {
            $this->removeAddressRelation($contact, $addressRelation);

            return true;
        };

        $update = function($addressRelation, $matchedEntry) use ($contact) {
            $address = $addressRelation->getAddress();
            $result = $this->updateAddress($address, $matchedEntry, $isMain);
            if ($isMain) {
                $this->unsetMain($this->getAddressRelations($contact));
            }
            $addressRelation->setMain($isMain);

            return $result;
        };

        $add = function($addressData) use ($contact) {
            $address = $this->createAddress($addressData, $isMain);
            $this->addAddress($contact, $address, $isMain);

            return true;
        };

        $entities = $this->getAddressRelations($contact);

        $result = $this->processSubEntities(
            $entities,
            $addresses,
            $getAddressId,
            $add,
            $update,
            $delete
        );

        $this->resetIndexOfSubentites($entities);

        // check if main exists, else take first address
        $this->checkAndSetMainAddress($this->getAddressRelations($contact));

        return $result;
    }
public function processAddresses ( $ contact , $ addresses ) { $ getAddressId = function ( $ addressRelation ) { return $ addressRelation -> getAddress ( ) -> getId ( ) ; } ; $ delete = function ( $ addressRelation ) use ( $ contact ) { $ this -> removeAddressRelation ( $ contact , $ addressRelation ) ; return true ; } ; $ update = function ( $ addressRelation , $ matchedEntry ) use ( $ contact ) { $ address = $ addressRelation -> getAddress ( ) ; $ result = $ this -> updateAddress ( $ address , $ matchedEntry , $ isMain ) ; if ( $ isMain ) { $ this -> unsetMain ( $ this -> getAddressRelations ( $ contact ) ) ; } $ addressRelation -> setMain ( $ isMain ) ; return $ result ; } ; $ add = function ( $ addressData ) use ( $ contact ) { $ address = $ this -> createAddress ( $ addressData , $ isMain ) ; $ this -> addAddress ( $ contact , $ address , $ isMain ) ; return true ; } ; $ entities = $ this -> getAddressRelations ( $ contact ) ; $ result = $ this -> processSubEntities ( $ entities , $ addresses , $ getAddressId , $ add , $ update , $ delete ) ; $ this -> resetIndexOfSubentites ( $ entities ) ; // check if main exists, else take first address $ this -> checkAndSetMainAddress ( $ this -> getAddressRelations ( $ contact ) ) ; return $ result ; }
Process all addresses from request.

@param $contact The contact on which is worked
@param array $addresses

@return bool True if the processing was sucessful, otherwise false
Process all addresses from request .