public function deleteAction($id, $source = null)
{
$translator = $this->get('translator');
/**
* @var CustomerInterface $customer
*/
$customer = $this->getUser();
$address = $this->get('elcodi.repository.customer')->findAddress($customer->getId(), $id);
if (!$address instanceof AddressInterface) {
throw new NotFoundHttpException('Address not found');
}
$customerManager = $this->get('elcodi.object_manager.customer');
$customer->removeAddress($address);
$customerManager->flush($customer);
$message = $translator->trans('store.address.delete.response_ok');
$this->addFlash('success', $message);
$redirectUrl = self::CHECKOUT_SOURCE == $source ? 'store_checkout_address' : 'store_address_list';
return $this->redirect($this->generateUrl($redirectUrl));
}