validate create and update address in front context
This commit is contained in:
@@ -22,6 +22,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.address" class="Thelia\Action\Address">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.image" class="Thelia\Action\Image">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
<form name="thelia.customer.login" class="Thelia\Form\CustomerLogin"/>
|
||||
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
|
||||
|
||||
<form name="thelia.address.create" class="Thelia\Form\AddressCreateForm" />
|
||||
<form name="thelia.address.update" class="Thelia\Form\AddressUpdateForm" />
|
||||
|
||||
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
|
||||
<form name="thelia.admin.category.deletion" class="Thelia\Form\CategoryDeletionForm"/>
|
||||
|
||||
|
||||
@@ -30,7 +30,17 @@
|
||||
|
||||
<!-- customer address routes -->
|
||||
<route id="address.create" path="/address/create" >
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerAddressController::createAction</default>
|
||||
<default key="_controller">Thelia\Controller\Front\AddressController::createAction</default>
|
||||
<default key="_view">address</default>
|
||||
</route>
|
||||
|
||||
<route id="address.edit" path="/address/edit/{address_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">address_edit</default>
|
||||
</route>
|
||||
|
||||
<route id="address.update" path="/address/update" >
|
||||
<default key="_controller">Thelia\Controller\Front\AddressController::updateAction</default>
|
||||
</route>
|
||||
<!-- end customer address routes -->
|
||||
|
||||
@@ -50,7 +60,7 @@
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="url-rewriting.check" path="/{rewritten_url}" methods="GET">
|
||||
<!-- <route id="url-rewriting.check" path="/{rewritten_url}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Front\UrlRewritingController::check</default>
|
||||
</route>
|
||||
</route>-->
|
||||
</routes>
|
||||
|
||||
@@ -24,33 +24,41 @@
|
||||
namespace Thelia\Controller\Front;
|
||||
use Thelia\Core\Event\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\AddressForm;
|
||||
use Thelia\Form\AddressCreateForm;
|
||||
use Thelia\Form\AddressUpdateForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\Base\AddressQuery;
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
|
||||
/**
|
||||
* Class CustomerAddressController
|
||||
* Class AddressController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class CustomerAddressController extends BaseFrontController
|
||||
class AddressController extends BaseFrontController
|
||||
{
|
||||
|
||||
/**
|
||||
* Create controller.
|
||||
* Check if customer is logged in
|
||||
*
|
||||
* Dispatch TheliaEvents::ADDRESS_CREATE event
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirect(URL::getIndexPage());
|
||||
}
|
||||
|
||||
$addressCreate = new AddressForm($this->getRequest());
|
||||
$addressCreate = new AddressCreateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($addressCreate, "post");
|
||||
$event = $this->createAddressEvent($form->getData());
|
||||
$event = $this->createAddressEvent($form);
|
||||
$event->setCustomer($customer);
|
||||
|
||||
$this->dispatch(TheliaEvents::ADDRESS_CREATE, $event);
|
||||
@@ -77,25 +85,74 @@ class CustomerAddressController extends BaseFrontController
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirectToRoute("home");
|
||||
}
|
||||
|
||||
if(null === $address_id = $request->get("address_id")) {
|
||||
$this->redirectToRoute("home");
|
||||
}
|
||||
|
||||
$addressUpdate = new AddressUpdateForm($request);
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($addressUpdate);
|
||||
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (null === $address) {
|
||||
$this->redirectToRoute("home");
|
||||
}
|
||||
|
||||
if($address->getCustomer()->getId() != $customer->getId()) {
|
||||
$this->redirectToRoute("home");
|
||||
}
|
||||
|
||||
$event = $this->createAddressEvent($form);
|
||||
$event->setAddress($address);
|
||||
|
||||
$this->dispatch(TheliaEvents::ADDRESS_UPDATE, $event);
|
||||
|
||||
$this->redirectSuccess($addressUpdate);
|
||||
}catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error during address creation process : %s", $message));
|
||||
|
||||
$addressUpdate->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($addressUpdate)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
protected function createAddressEvent($data)
|
||||
protected function createAddressEvent($form)
|
||||
{
|
||||
return new AddressCreateOrUpdateEvent(
|
||||
$data["label"],
|
||||
$data["title"],
|
||||
$data["firstname"],
|
||||
$data["lastname"],
|
||||
$data["address1"],
|
||||
$data["address2"],
|
||||
$data["address3"],
|
||||
$data["zipcode"],
|
||||
$data["city"],
|
||||
$data["country"],
|
||||
$data["cellpone"],
|
||||
$data["phone"],
|
||||
$data["company"]
|
||||
$form->get("label")->getData(),
|
||||
$form->get("title")->getData(),
|
||||
$form->get("firstname")->getData(),
|
||||
$form->get("lastname")->getData(),
|
||||
$form->get("address1")->getData(),
|
||||
$form->get("address2")->getData(),
|
||||
$form->get("address3")->getData(),
|
||||
$form->get("zipcode")->getData(),
|
||||
$form->get("city")->getData(),
|
||||
$form->get("country")->getData(),
|
||||
$form->get("cellphone")->getData(),
|
||||
$form->get("phone")->getData(),
|
||||
$form->get("company")->getData()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
namespace Thelia\Controller\Front;
|
||||
|
||||
use Thelia\Controller\BaseController;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class BaseFrontController extends BaseController
|
||||
{
|
||||
|
||||
@@ -56,13 +56,16 @@ class DefaultController extends BaseFrontController
|
||||
}
|
||||
}
|
||||
|
||||
$view = null;
|
||||
|
||||
if (! $view = $request->query->get('view')) {
|
||||
$view = "index";
|
||||
if ($request->request->has('view')) {
|
||||
$view = $request->request->get('view');
|
||||
}
|
||||
}
|
||||
if(!is_null($view)) {
|
||||
$request->attributes->set('_view', $view);
|
||||
}
|
||||
|
||||
$request->attributes->set('_view', $view);
|
||||
}
|
||||
}
|
||||
|
||||
54
core/lib/Thelia/Core/Event/AddressEvent.php
Normal file
54
core/lib/Thelia/Core/Event/AddressEvent.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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 Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Model\Address;
|
||||
|
||||
|
||||
/**
|
||||
* Class AddressEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AddressEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Address
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
function __construct(Address $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Address
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
}
|
||||
@@ -88,12 +88,13 @@ final class TheliaEvents
|
||||
/**
|
||||
* Sent once the customer change form has been successfully validated, and before customer update in the database.
|
||||
*/
|
||||
const BEFORE_CHANGECUSTOMER = "action.before_updateCustomer";
|
||||
const BEFORE_UPDATECUSTOMER = "action.before_updateCustomer";
|
||||
/**
|
||||
* Sent just after a successful update of a customer in the database.
|
||||
*/
|
||||
const AFTER_CHANGECUSTOMER = "action.after_updateCustomer";
|
||||
const AFTER_UPDATECUSTOMER = "action.after_updateCustomer";
|
||||
|
||||
// -- ADDRESS MANAGEMENT ---------------------------------------------------------
|
||||
/**
|
||||
* sent for address creation
|
||||
*/
|
||||
@@ -104,6 +105,17 @@ final class TheliaEvents
|
||||
*/
|
||||
const ADDRESS_UPDATE = "action.updateAddress";
|
||||
|
||||
const BEFORE_CREATEADDRESS = "action.before_createAddress";
|
||||
const AFTER_CREATEADDRESS = "action.after_createAddress";
|
||||
|
||||
const BEFORE_UPDATEADDRESS = "action.before_updateAddress";
|
||||
const AFTER_UPDATEADDRESS = "action.after_updateAddress";
|
||||
|
||||
const BEFORE_DELETEADDRESS = "action.before_deleteAddress";
|
||||
const AFTER_DELETEADDRESS = "action.after_deleteAddress";
|
||||
|
||||
// -- END ADDRESS MANAGEMENT ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sent once the category creation form has been successfully validated, and before category insertion in the database.
|
||||
*/
|
||||
|
||||
@@ -61,7 +61,7 @@ class Address extends BaseLoop
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createBooleanTypeArgument('default'),
|
||||
Argument::createBooleanTypeArgument('default', false),
|
||||
Argument::createIntListTypeArgument('exclude')
|
||||
);
|
||||
}
|
||||
@@ -96,10 +96,9 @@ class Address extends BaseLoop
|
||||
|
||||
$default = $this->getDefault();
|
||||
|
||||
|
||||
if ($default === true) {
|
||||
$search->filterByIsDefault(1, Criteria::EQUAL);
|
||||
} elseif ($default === false) {
|
||||
$search->filterByIsDefault(1, Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
@@ -116,7 +115,7 @@ class Address extends BaseLoop
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow
|
||||
->set("ID", $address->getId())
|
||||
->set("NAME", $address->getName())
|
||||
->set("LABEL", $address->getLabel())
|
||||
->set("CUSTOMER", $address->getCustomerId())
|
||||
->set("TITLE", $address->getTitleId())
|
||||
->set("COMPANY", $address->getCompany())
|
||||
|
||||
@@ -26,11 +26,11 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
|
||||
/**
|
||||
* Class AddressForm
|
||||
* Class AddressCreateForm
|
||||
* @package Thelia\Form
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AddressForm extends BaseForm
|
||||
class AddressCreateForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,8 @@ class AddressForm extends BaseForm
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "address name"
|
||||
"label" => "address name",
|
||||
"required" => true
|
||||
))
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
69
core/lib/Thelia/Form/AddressUpdateForm.php
Normal file
69
core/lib/Thelia/Form/AddressUpdateForm.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Form;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
|
||||
/**
|
||||
* Class AddressUpdateForm
|
||||
* @package Thelia\Form
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AddressUpdateForm extends AddressCreateForm {
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_address_update";
|
||||
}
|
||||
}
|
||||
@@ -4,21 +4,12 @@ namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Event\AddressEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\Address as BaseAddress;
|
||||
|
||||
class Address extends BaseAddress {
|
||||
|
||||
protected $dispatcher;
|
||||
|
||||
public function setDispatcher(EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* Code to be run before inserting to database
|
||||
@@ -27,6 +18,7 @@ class Address extends BaseAddress {
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEADDRESS, new AddressEvent($this));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,7 +28,7 @@ class Address extends BaseAddress {
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEADDRESS, new AddressEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,6 +38,7 @@ class Address extends BaseAddress {
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEADDRESS, new AddressEvent($this));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -55,7 +48,7 @@ class Address extends BaseAddress {
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEADDRESS, new AddressEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +58,7 @@ class Address extends BaseAddress {
|
||||
*/
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,7 +68,7 @@ class Address extends BaseAddress {
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEADDRESS, new AddressEvent($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Base\Customer as BaseCustomer;
|
||||
|
||||
@@ -115,7 +115,7 @@ class Customer extends BaseCustomer implements UserInterface
|
||||
|
||||
$con->commit();
|
||||
|
||||
} catch(Exception $e) {
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ class Customer extends BaseCustomer implements UserInterface
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, new CustomerEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATECUSTOMER, new CustomerEvent($this));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ class Customer extends BaseCustomer implements UserInterface
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, new CustomerEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECUSTOMER, new CustomerEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1631,8 +1631,8 @@
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_ADMIN_LOGIN" class="">ADMIN_LOGIN</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_BEFORE_CREATECUSTOMER" class="">BEFORE_CREATECUSTOMER</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CREATECUSTOMER" class="">AFTER_CREATECUSTOMER</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_BEFORE_CHANGECUSTOMER" class="">BEFORE_CHANGECUSTOMER</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CHANGECUSTOMER" class="">AFTER_CHANGECUSTOMER</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_BEFORE_CHANGECUSTOMER" class="">BEFORE_UPDATECUSTOMER</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CHANGECUSTOMER" class="">AFTER_UPDATECUSTOMER</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_BEFORE_CREATECATEGORY" class="">BEFORE_CREATECATEGORY</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CREATECATEGORY" class="">AFTER_CREATECATEGORY</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_BEFORE_DELETECATEGORY" class="">BEFORE_DELETECATEGORY</a><br />
|
||||
@@ -1891,8 +1891,8 @@
|
||||
<div class="span8 content class">
|
||||
<a id="constant_BEFORE_CHANGECUSTOMER" name="constant_BEFORE_CHANGECUSTOMER" class="anchor"></a>
|
||||
<article id="constant_BEFORE_CHANGECUSTOMER" class="constant">
|
||||
<h3 class="">BEFORE_CHANGECUSTOMER</h3>
|
||||
<pre class="signature">BEFORE_CHANGECUSTOMER</pre>
|
||||
<h3 class="">BEFORE_UPDATECUSTOMER</h3>
|
||||
<pre class="signature">BEFORE_UPDATECUSTOMER</pre>
|
||||
<p><em>Sent once the customer change form has been successfully validated, and before customer update in the database.</em></p>
|
||||
|
||||
|
||||
@@ -1913,8 +1913,8 @@
|
||||
<div class="span8 content class">
|
||||
<a id="constant_AFTER_CHANGECUSTOMER" name="constant_AFTER_CHANGECUSTOMER" class="anchor"></a>
|
||||
<article id="constant_AFTER_CHANGECUSTOMER" class="constant">
|
||||
<h3 class="">AFTER_CHANGECUSTOMER</h3>
|
||||
<pre class="signature">AFTER_CHANGECUSTOMER</pre>
|
||||
<h3 class="">AFTER_UPDATECUSTOMER</h3>
|
||||
<pre class="signature">AFTER_UPDATECUSTOMER</pre>
|
||||
<p><em>Sent just after a successful update of a customer in the database.</em></p>
|
||||
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
$customer = CustomerQuery::create()->findPk(1);
|
||||
try {
|
||||
$customerEvent = new CustomerEvent($customer);
|
||||
$event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CHANGECUSTOMER, $customerEvent);
|
||||
$event->getDispatcher()->dispatch(TheliaEvents::BEFORE_UPDATECUSTOMER, $customerEvent);
|
||||
|
||||
$data = $form->getData();
|
||||
|
||||
@@ -127,7 +127,7 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
);
|
||||
|
||||
$customerEvent->customer = $customer;
|
||||
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECUSTOMER, $customerEvent);
|
||||
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_UPDATECUSTOMER, $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.
|
||||
|
||||
@@ -78,11 +78,11 @@ final class TheliaEvents
|
||||
/**
|
||||
* Sent once the customer change form has been successfully validated, and before customer update in the database.
|
||||
*/
|
||||
const BEFORE_CHANGECUSTOMER = "action.before_changecustomer";
|
||||
const BEFORE_UPDATECUSTOMER = "action.before_changecustomer";
|
||||
/**
|
||||
* Sent just after a successful update of a customer in the database.
|
||||
*/
|
||||
const AFTER_CHANGECUSTOMER = "action.after_changecustomer";
|
||||
const AFTER_UPDATECUSTOMER = "action.after_changecustomer";
|
||||
|
||||
/**
|
||||
* Sent once the category creation form has been successfully validated, and before category insertion in the database.
|
||||
|
||||
@@ -125,7 +125,7 @@ class Customer extends BaseCustomer implements UserInterface
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$customerEvent = new CustomerEvent($this);
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECUSTOMER, $customerEvent);
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATECUSTOMER, $customerEvent);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class Customer extends BaseCustomer implements UserInterface
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$customerEvent = new CustomerEvent($this);
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECUSTOMER, $customerEvent);
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECUSTOMER, $customerEvent);
|
||||
}
|
||||
|
||||
protected function dispatchEvent($eventName, CustomerEvent $customerEvent)
|
||||
|
||||
99
templates/default/address.html
Normal file
99
templates/default/address.html
Normal file
@@ -0,0 +1,99 @@
|
||||
{check_auth context="front" roles="CUSTOMER" login_tpl="login"}
|
||||
{include file="includes/header.html"}
|
||||
{$page_title="{intl l='My Account'}"}
|
||||
|
||||
|
||||
{form name="thelia.address.create"}
|
||||
{if $form_error}<div class="alert alert-block alert-error">{$form_error_message}</div>{/if}
|
||||
{* We use {navigate to="index"} as form action to avoid mixing post and get data *}
|
||||
<form action="{url path="/address/create" }" method="post" {form_enctype form=$form}>
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{viewurl view="address_list"}" />
|
||||
{/form_field}
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field="label"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="title"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<select name="{$name}">
|
||||
{loop type="title" name="title1"}
|
||||
<option value="#ID">#LONG</option>
|
||||
{/loop}
|
||||
|
||||
</select>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="firstname"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="lastname"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="address1"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
{form_field form=$form field="zipcode"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="city"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="country"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<select name="{$name}">
|
||||
{loop type="country" name="country1"}
|
||||
<option value="#ID">#TITLE</option>
|
||||
{/loop}
|
||||
|
||||
</select>
|
||||
<br />
|
||||
{/form_field}
|
||||
{form_field form=$form field="phone"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
<input type="submit" value="submit">
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
|
||||
{include file="includes/footer.html"}
|
||||
100
templates/default/address_edit.html
Normal file
100
templates/default/address_edit.html
Normal file
@@ -0,0 +1,100 @@
|
||||
{check_auth context="front" roles="CUSTOMER" login_tpl="login"}
|
||||
{include file="includes/header.html"}
|
||||
{$page_title="{intl l='My Account'}"}
|
||||
|
||||
|
||||
{form name="thelia.address.update"}
|
||||
{if $form_error}<div class="alert alert-block alert-error">{$form_error_message}</div>{/if}
|
||||
{* We use {navigate to="index"} as form action to avoid mixing post and get data *}
|
||||
<form action="{url path="/address/update" }" method="post" {form_enctype form=$form}>
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{viewurl view="address_list"}" />
|
||||
{/form_field}
|
||||
<input type="hidden" name="address_id" value="5" />
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field="label"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="title"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<select name="{$name}">
|
||||
{loop type="title" name="title1"}
|
||||
<option value="#ID">#LONG</option>
|
||||
{/loop}
|
||||
|
||||
</select>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="firstname"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="lastname"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="address1"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
{form_field form=$form field="zipcode"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="city"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="country"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<select name="{$name}">
|
||||
{loop type="country" name="country1"}
|
||||
<option value="#ID">#TITLE</option>
|
||||
{/loop}
|
||||
|
||||
</select>
|
||||
<br />
|
||||
{/form_field}
|
||||
{form_field form=$form field="phone"}
|
||||
{if $error}{$message}{/if}
|
||||
|
||||
<label> <span>{intl l="{$label}"} : </span></label>
|
||||
<input type="text" name="{$name}" value="{$value}" {$attr}>
|
||||
<br />
|
||||
{/form_field}
|
||||
<input type="submit" value="submit">
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
|
||||
{include file="includes/footer.html"}
|
||||
11
templates/default/address_list.html
Normal file
11
templates/default/address_list.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{check_auth context="front" roles="CUSTOMER" login_tpl="login"}
|
||||
{include file="includes/header.html"}
|
||||
{$page_title="{intl l='My Account'}"}
|
||||
|
||||
<ul>
|
||||
{loop type="address" name="customer_list" customer="current"}
|
||||
<li>{#LABEL} - {#FIRSTNAME} {#LASTNAME} - <a href="{url path="/address/edit/{#ID}"}">edit</a></li>
|
||||
{/loop}
|
||||
</ul>
|
||||
|
||||
{include file="includes/footer.html"}
|
||||
@@ -7,7 +7,6 @@
|
||||
The two fields below are not par of the form, they are here to defines
|
||||
the action to process, and the view to render once the form is submited
|
||||
*}
|
||||
<input type="hidden" name="action" value="createCustomer" /> {* the action triggered by this form *}
|
||||
|
||||
{*
|
||||
This field is common to all BaseForm instances (thus, this one), and defines
|
||||
|
||||
Reference in New Issue
Block a user