/** * Remove deliveryAddress if it has a relation to a certain contact-address-id * * @param Item $item * @param int $contactAddressId */ protected function removeOrderAddressIfContactAddressIdIsEqualTo($item, $contactAddressId) { $deliveryAddress = $item->getDeliveryAddress(); if ($deliveryAddress && $deliveryAddress->getContactAddress() && $deliveryAddress->getContactAddress()->getID() === $contactAddressId) { $item->setDeliveryAddress(null); $this->em->remove($deliveryAddress); } }