allow address removal from front

This commit is contained in:
Manuel Raynaud
2013-09-13 12:33:13 +02:00
parent ddf175f361
commit 8367863b48
5 changed files with 73 additions and 4 deletions

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Front;
use Thelia\Core\Event\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\AddressCreateForm;
use Thelia\Form\AddressUpdateForm;
@@ -154,6 +155,22 @@ class AddressController extends BaseFrontController
}
}
public function deleteAction($address_id)
{
$this->checkAuth();
$customer = $this->getSecurityContext()->getCustomerUser();
$address = AddressQuery::create()->findPk($address_id);
if(!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home");
}
$this->dispatch(TheliaEvents::ADDRESS_DELETE, new AddressEvent($address));
$this->redirectToRoute("customer.account.view");
}
protected function createAddressEvent($form)
{
return new AddressCreateOrUpdateEvent(