create error message when a customer is deleted and already have orders.

Fix #199
This commit is contained in:
Manuel Raynaud
2014-02-19 10:41:26 +01:00
parent 5caa55c345
commit 16275ef51a
5 changed files with 74 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Exception\CustomerException;
use Thelia\Form\CustomerCreateForm;
use Thelia\Form\CustomerUpdateForm;
use Thelia\Model\CustomerQuery;
@@ -178,13 +179,14 @@ class CustomerController extends AbstractCrudController
);
}
protected function renderListTemplate($currentOrder)
protected function renderListTemplate($currentOrder, $customParams = array())
{
return $this->render('customers', array(
return $this->render('customers', array_merge(array(
'customer_order' => $currentOrder,
'display_customer' => 20,
'page' => $this->getRequest()->get('page', 1)
));
), $customParams)
);
}
protected function redirectToListTemplate()
@@ -203,4 +205,18 @@ class CustomerController extends AbstractCrudController
{
$this->redirectToRoute("admin.customer.update.view", $this->getEditionArguments());
}
public function deleteAction()
{
try {
parent::deleteAction();
} catch (CustomerException $e) {
$error_msg = $e->getMessage();
}
return $this->renderListTemplate($this->getCurrentListOrder(), array(
"removal_error" => true,
"error_message" => $error_msg
));
}
}