This commit is contained in:
Franck Allimant
2013-10-25 00:33:52 +02:00
31 changed files with 1096 additions and 119 deletions

View File

@@ -30,7 +30,7 @@ use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\AccessManager;
use Thelia\Form\CustomerModification;
use Thelia\Form\CustomerUpdateForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\CustomerQuery;
use Thelia\Core\Translation\Translator;
@@ -68,7 +68,7 @@ class CustomerController extends BaseAdminController
$message = false;
$customerModification = new CustomerModification($this->getRequest());
$customerUpdateForm = new CustomerUpdateForm($this->getRequest());
try {
$customer = CustomerQuery::create()->findPk($customer_id);
@@ -77,7 +77,7 @@ class CustomerController extends BaseAdminController
throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id));
}
$form = $this->validateForm($customerModification);
$form = $this->validateForm($customerUpdateForm);
$event = $this->createEventInstance($form->getData());
$event->setCustomer($customer);
@@ -91,7 +91,7 @@ class CustomerController extends BaseAdminController
if ($this->getRequest()->get("save_mode") == "close") {
$this->redirectToRoute("admin.customers");
} else {
$this->redirectSuccess($customerModification);
$this->redirectSuccess($customerUpdateForm);
}
} catch (FormValidationException $e) {
@@ -105,10 +105,10 @@ class CustomerController extends BaseAdminController
if ($message !== false) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error during customer login process : %s.", $message));
$customerModification->setErrorMessage($message);
$customerUpdateForm->setErrorMessage($message);
$this->getParserContext()
->addForm($customerModification)
->addForm($customerUpdateForm)
->setGeneralError($message)
;
}

View File

@@ -45,10 +45,8 @@ class MessageController extends AbstractCrudController
null, // no sort order change
null, // no sort order change
AdminResources::MESSAGE_VIEW,
AdminResources::MESSAGE_CREATE,
AdminResources::MESSAGE_UPDATE,
AdminResources::MESSAGE_DELETE,
AdminResources::MESSAGE,
TheliaEvents::MESSAGE_CREATE,
TheliaEvents::MESSAGE_UPDATE,

View File

@@ -101,7 +101,7 @@ class AddressController extends BaseFrontController
$address = AddressQuery::create()->findPk($address_id);
if (!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home");
$this->redirectToRoute('default');
}
$this->getParserContext()->set("address_id", $address_id);
@@ -122,11 +122,11 @@ class AddressController extends BaseFrontController
$address = AddressQuery::create()->findPk($address_id);
if (null === $address) {
$this->redirectToRoute("home");
$this->redirectToRoute('default');
}
if ($address->getCustomer()->getId() != $customer->getId()) {
$this->redirectToRoute("home");
$this->redirectToRoute('default');
}
$event = $this->createAddressEvent($form);
@@ -161,12 +161,12 @@ class AddressController extends BaseFrontController
$address = AddressQuery::create()->findPk($address_id);
if (!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home");
$this->redirectToRoute('default');
}
$this->dispatch(TheliaEvents::ADDRESS_DELETE, new AddressEvent($address));
$this->redirectToRoute("customer.account.view");
$this->redirectToRoute('default', array('view'=>'account'));
}
protected function createAddressEvent($form)

View File

@@ -56,7 +56,7 @@ class BaseFrontController extends BaseController
public function checkAuth()
{
if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirectToRoute("customer.login.view");
$this->redirectToRoute('default', array('view'=>'login'));
}
}
@@ -64,7 +64,7 @@ class BaseFrontController extends BaseController
{
$cart = $this->getSession()->getCart();
if ($cart===null || $cart->countCartItems() == 0) {
$this->redirectToRoute("cart.view");
$this->redirectToRoute('cart.view');
}
}

View File

@@ -109,7 +109,7 @@ class CustomerController extends BaseFrontController
$cart = $this->getCart($this->getRequest());
if ($cart->getCartItems()->count() > 0) {
$this->redirectToRoute("cart.view");
$this->redirectToRoute('cart.view');
} else {
$this->redirectSuccess($customerCreation);
}
@@ -278,7 +278,7 @@ class CustomerController extends BaseFrontController
// If User is a new customer
if ($form->get('account')->getData() == 0 && !$form->get("email")->getErrors()) {
$this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData()));
$this->redirectToRoute("default", array("view" => "register","email" => $form->get("email")->getData()));
} else {
try {

View File

@@ -197,7 +197,7 @@ class OrderController extends BaseFrontController
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId()))));
} else {
/* order has not been placed */
$this->redirectToRoute("cart.view");
$this->redirectToRoute('cart.view');
}
}