validate create and update address in front context

This commit is contained in:
Manuel Raynaud
2013-09-04 17:52:58 +02:00
parent 3cb4e6ff2e
commit ceb02841e1
21 changed files with 482 additions and 65 deletions

View 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;
}
}

View File

@@ -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.
*/

View File

@@ -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())