From eeab96bde6800a6f8edbe808d22f7357f9c58010 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 3 Oct 2013 16:10:28 +0200 Subject: [PATCH] redirect to customer update template after removing address --- core/lib/Thelia/Action/Customer.php | 10 --- .../Controller/Admin/BaseAdminController.php | 4 +- .../Controller/Admin/CustomerController.php | 9 ++- .../Event/Customer/CustomerAddressEvent.php | 66 ------------------- 4 files changed, 6 insertions(+), 83 deletions(-) delete mode 100644 core/lib/Thelia/Core/Event/Customer/CustomerAddressEvent.php diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 46a7396c1..85643cb88 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -111,15 +111,6 @@ class Customer extends BaseAction implements EventSubscriberInterface $this->getSecurityContext()->clearCustomerUser(); } - public function deleteAddress(CustomerAddressEvent $event) - { - $address = $event->getAddress(); - - $address->delete(); - - $event->setAddress($address); - } - public function changePassword(ActionEvent $event) { // TODO @@ -163,7 +154,6 @@ class Customer extends BaseAction implements EventSubscriberInterface TheliaEvents::CUSTOMER_LOGOUT => array('logout', 128), TheliaEvents::CUSTOMER_LOGIN => array('login', 128), TheliaEvents::CUSTOMER_DELETEACCOUNT => array('delete', 128), - TheliaEvents::CUSTOMER_ADDRESS_DELETE => array('deleteAddress', 128) ); } } diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 61fc80940..5d99a877b 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -246,9 +246,9 @@ class BaseAdminController extends BaseController * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml * @param unknown $urlParameters the URL parametrs, as a var/value pair array */ - public function redirectToRoute($routeId, $urlParameters = array()) + public function redirectToRoute($routeId, $urlParameters = array(), $routeParameters = array()) { - $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters)); + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, $routeParameters), $urlParameters)); } /** diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index 0c320f0d4..346a36b97 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -25,6 +25,7 @@ namespace Thelia\Controller\Admin; use Propel\Runtime\Exception\PropelException; use Symfony\Component\Form\Form; +use Thelia\Core\Event\Address\AddressEvent; use Thelia\Core\Event\Customer\CustomerAddressEvent; use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\Customer\CustomerEvent; @@ -69,18 +70,16 @@ class CustomerController extends BaseAdminController throw new \InvalidArgumentException(sprintf('%d address does not exists', $address_id)); } - $addressEvent = new CustomerAddressEvent($address); + $addressEvent = new AddressEvent($address); - $this->dispatch(TheliaEvents::CUSTOMER_ADDRESS_DELETE, $addressEvent); + $this->dispatch(TheliaEvents::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() - )); + $this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId())); } /** diff --git a/core/lib/Thelia/Core/Event/Customer/CustomerAddressEvent.php b/core/lib/Thelia/Core/Event/Customer/CustomerAddressEvent.php deleted file mode 100644 index 6c4c82d3d..000000000 --- a/core/lib/Thelia/Core/Event/Customer/CustomerAddressEvent.php +++ /dev/null @@ -1,66 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Event\Customer; - -use Thelia\Core\Event\ActionEvent; -use Thelia\Model\Address; - - -/** - * Class CustomerAddressEvent - * @package Thelia\Core\Event\Customer - * @author Manuel Raynaud - */ -class CustomerAddressEvent extends ActionEvent -{ - /** - * @var \Thelia\Model\Address - */ - protected $address; - - /** - * @param Address $address - */ - public function __construct(Address $address) - { - $this->address = $address; - } - - /** - * @param \Thelia\Model\Address $address - */ - public function setAddress($address) - { - $this->address = $address; - } - - /** - * @return \Thelia\Model\Address - */ - public function getAddress() - { - return $this->address; - } - -} \ No newline at end of file