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

@@ -31,6 +31,8 @@ use Thelia\Core\Event\LostPasswordEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\SecurityContext;
use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Exception\CustomerException;
use Thelia\Mailer\MailerFactory;
use Thelia\Model\ConfigQuery;
use Thelia\Model\Customer as CustomerModel;
@@ -106,6 +108,10 @@ class Customer extends BaseAction implements EventSubscriberInterface
{
if (null !== $customer = $event->getCustomer()) {
if (true === $customer->hasOrder()) {
throw new CustomerException(Translator::getInstance()->trans("Impossible to delete a customer who already have orders"));
}
$customer->delete();
}
}