change event class for customer actions

This commit is contained in:
Manuel Raynaud
2013-08-02 16:10:26 +02:00
parent 3a99023c1d
commit 265a6bb2a8
2 changed files with 45 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\BaseForm;
use Thelia\Form\CustomerCreation;
@@ -88,8 +89,8 @@ class Customer implements EventSubscriberInterface
$data["password"],
$request->getSession()->getLang()
);
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $event);
$customerEvent = new CustomerEvent($customer);
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $customerEvent);
// Connect the newly created user,and redirect to the success URL
$this->processSuccessfulLogin($event, $customer, $customerCreationForm, true);
@@ -136,7 +137,8 @@ class Customer implements EventSubscriberInterface
$customer = CustomerQuery::create()->findPk(1);
try {
$event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECUSTOMER, $event);
$customerEvent = new CustomerEvent($customer);
$event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECUSTOMER, $customerEvent);
$data = $form->getData();
@@ -153,7 +155,8 @@ class Customer implements EventSubscriberInterface
$data["country"]
);
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECUSTOMER, $event);
$customerEvent->customer = $customer;
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECUSTOMER, $customerEvent);
// Update the logged-in user, and redirect to the success URL (exits)
// We don-t send the login event, as the customer si already logged.

View File

@@ -0,0 +1,38 @@
<?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;
use Thelia\Model\Customer;
class CustomerEvent extends InternalEvent {
public $customer;
public function __construct(Customer $customer)
{
$this->customer = $customer;
}
}