public function saveAddress(AddressInterface $address)
    {
        if ($address->getId()) {
            $addressToSave = clone $address;
            $addressToSave->setId(null);

            $this->addressObjectManager->refresh($address);
            $this->addressObjectManager->persist($addressToSave);
            $this->addressObjectManager->flush($addressToSave);

            $this->addressEventDispatcher->dispatchAddressOnCloneEvent(
                $address,
                $addressToSave
            );

            return $addressToSave;
        }

        $this
            ->addressObjectManager
            ->flush($address);

        return $address;
    }
public function saveAddress(AddressInterface $address)
    {
        if ($address->getId()) {
            $addressToSave = clone $address;
            $addressToSave->setId(null);

            $this->addressObjectManager->refresh($address);
            $this->addressObjectManager->persist($addressToSave);
            $this->addressObjectManager->flush($addressToSave);

            $this->addressEventDispatcher->dispatchAddressOnCloneEvent(
                $address,
                $addressToSave
            );

            return $addressToSave;
        }

        $this
            ->addressObjectManager
            ->flush($address);

        return $address;
    }
public function saveAddress ( AddressInterface $ address ) { if ( $ address -> getId ( ) ) { $ addressToSave = clone $ address ; $ addressToSave -> setId ( null ) ; $ this -> addressObjectManager -> refresh ( $ address ) ; $ this -> addressObjectManager -> persist ( $ addressToSave ) ; $ this -> addressObjectManager -> flush ( $ addressToSave ) ; $ this -> addressEventDispatcher -> dispatchAddressOnCloneEvent ( $ address , $ addressToSave ) ; return $ addressToSave ; } $ this -> addressObjectManager -> flush ( $ address ) ; return $ address ; }
Saves an address making a copy in case it was already persisted. Then
returns the saved address.

@param AddressInterface $address The address to save

@return AddressInterface saved address.
Saves an address making a copy in case it was already persisted . Then returns the saved address .