diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index a794035e2..7a26d40b6 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -25,6 +25,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Form\BaseForm; use Thelia\Form\CustomerCreation; @@ -33,6 +34,9 @@ class Customer implements EventSubscriberInterface public function create(ActionEvent $event) { + + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECUSTOMER, $event); + $request = $event->getRequest(); $customerForm = new CustomerCreation($request); @@ -49,6 +53,8 @@ class Customer implements EventSubscriberInterface $event->setFormError($form); } } + + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $event); } public function modify(ActionEvent $event) diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 3ffac068f..8f44d7fb5 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -47,4 +47,8 @@ final class TheliaEvents * Send before starting thelia inclusion */ const INCLUSION = "thelia.include"; + + const BEFORE_CREATECUSTOMER = "action.before_createcustomer"; + + const AFTER_CREATECUSTOMER = "action.after_createcustomer"; } diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index bcfacbf8a..a925d3d56 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -24,7 +24,8 @@ namespace Thelia\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Constraints; +use Thelia\Model\ConfigQuery; class CustomerCreation extends BaseForm @@ -32,18 +33,47 @@ class CustomerCreation extends BaseForm protected function buildForm() { - $this->form->add("name", "text") - ->add("email", "email", array( - "attr" => array( - "class" => "field" - ), - "label" => "email", - "constraints" => array( - new NotBlank() - ) + $this->form + ->add("firstname", "text", array( + "constraints" => array( + new Constraints\NotBlank() ) - ) - ->add('age', 'integer'); + )) + ->add("lastname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("email", "email", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Email() + ) + )) + ->add("address1", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("address2", "text") + ->add("address3", "text") + ->add("zipcode", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("country", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("password", "password", array( + "constraints" => array( + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ) + )) + + ; } public function getName()