change method to retrieve data in customer create process

This commit is contained in:
Manuel Raynaud
2013-09-12 09:48:24 +02:00
parent 6b9db1a162
commit 6fea7ef441

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Controller\Front; namespace Thelia\Controller\Front;
use Symfony\Component\Form\Form;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerLoginEvent; use Thelia\Core\Event\CustomerLoginEvent;
use Thelia\Core\Event\LostPasswordEvent; use Thelia\Core\Event\LostPasswordEvent;
@@ -97,7 +98,7 @@ class CustomerController extends BaseFrontController
try { try {
$form = $this->validateForm($customerCreation, "post"); $form = $this->validateForm($customerCreation, "post");
$customerCreateEvent = $this->createEventInstance($form->getData()); $customerCreateEvent = $this->createEventInstance($form);
$this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent); $this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);
@@ -146,7 +147,7 @@ class CustomerController extends BaseFrontController
$form = $this->validateForm($customerModification, "post"); $form = $this->validateForm($customerModification, "post");
$customerChangeEvent = $this->createEventInstance($form->getData()); $customerChangeEvent = $this->createEventInstance($form);
$customerChangeEvent->setCustomer($customer); $customerChangeEvent->setCustomer($customer);
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $customerChangeEvent); $this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $customerChangeEvent);
@@ -259,27 +260,27 @@ class CustomerController extends BaseFrontController
* @param $data * @param $data
* @return CustomerCreateOrUpdateEvent * @return CustomerCreateOrUpdateEvent
*/ */
private function createEventInstance($data) private function createEventInstance(Form $form)
{ {
$customerCreateEvent = new CustomerCreateOrUpdateEvent( $customerCreateEvent = new CustomerCreateOrUpdateEvent(
$data["title"], $form->get("title")->getData(),
$data["firstname"], $form->get("firstname")->getData(),
$data["lastname"], $form->get("lastname")->getData(),
$data["address1"], $form->get("address1")->getData(),
$data["address2"], $form->get("address2")->getData(),
$data["address3"], $form->get("address3")->getData(),
$data["phone"], $form->get("phone")->getData(),
$data["cellphone"], $form->get("cellphone")->getData(),
$data["zipcode"], $form->get("zipcode")->getData(),
$data["city"], $form->get("city")->getData(),
$data["country"], $form->get("country")->getData(),
isset($data["email"])?$data["email"]:null, $form->get("email")->getData(),
isset($data["password"]) ? $data["password"]:null, $form->get("password")->getData(),
$this->getRequest()->getSession()->getLang()->getId(), $this->getRequest()->getSession()->getLang()->getId(),
isset($data["reseller"])?$data["reseller"]:null, $form->get("reseller")->getData(),
isset($data["sponsor"])?$data["sponsor"]:null, $form->get("sponsor")->getData(),
isset($data["discount"])?$data["discount"]:null, $form->get("discount")->getData(),
isset($data["company"])?$data["company"]:null $form->get("company")->getData()
); );
return $customerCreateEvent; return $customerCreateEvent;