allow to delete customer address
This commit is contained in:
@@ -51,7 +51,7 @@ class BaseAdminController extends BaseController
|
||||
/**
|
||||
* Helper to append a message to the admin log.
|
||||
*
|
||||
* @param unknown $message
|
||||
* @param string $message
|
||||
*/
|
||||
public function adminLogAppend($message)
|
||||
{
|
||||
|
||||
@@ -22,13 +22,16 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Thelia\Core\Event\Customer\CustomerAddressEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\CustomerModification;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
@@ -53,6 +56,33 @@ class CustomerController extends BaseAdminController
|
||||
));
|
||||
}
|
||||
|
||||
public function deleteAddressAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.customer.update")) return $response;
|
||||
|
||||
$address_id = $this->getRequest()->request->get('address_id');
|
||||
|
||||
try {
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (null === $address) {
|
||||
throw new \InvalidArgumentException(sprintf('%d address does not exists', $address_id));
|
||||
}
|
||||
|
||||
$addressEvent = new CustomerAddressEvent($address);
|
||||
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_ADDRESS_DELETE, $addressEvent);
|
||||
|
||||
$this->adminLogAppend(sprintf("address %d for customer %d removal", $address_id, $address->getCustomerId()));
|
||||
} catch(\Exception $e) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during address removal with message %s", $e->getMessage()));
|
||||
}
|
||||
|
||||
return $this->render("customer-edit", array(
|
||||
"customer_id" => $address->getCustomerId()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* update customer action
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user