redirect to customer update template after removing address

This commit is contained in:
Manuel Raynaud
2013-10-03 16:10:28 +02:00
parent fa45df3275
commit eeab96bde6
4 changed files with 6 additions and 83 deletions

View File

@@ -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)
);
}
}

View File

@@ -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));
}
/**

View File

@@ -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()));
}
/**

View File

@@ -1,66 +0,0 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event\Customer;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Address;
/**
* Class CustomerAddressEvent
* @package Thelia\Core\Event\Customer
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
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;
}
}