Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (22) and others # Via Manuel Raynaud (7) and others * 'master' of https://github.com/thelia/thelia: (32 commits) refactor name for updating actions choose UPDATE word for name actions add update address action and create tests 404 not found management Working Fix unset namespace modify travis script test rewriting exception Fixed minor bug in Currencies Finished currency edition Added route methods address action implementation hot fix rewriting add address create controller and event Added AdminUtilities Smarty plugin, optimized templates update customer model createOrUpdate method update address model fix redirect process in viewListener refactor reset_install script refactor install process, database management in dedicated class ... Conflicts: local/config/schema.xml reset_install.sh
This commit is contained in:
132
core/lib/Thelia/Form/AddressForm.php
Normal file
132
core/lib/Thelia/Form/AddressForm.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?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 AddressForm
|
||||
* @package Thelia\Form
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AddressForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* 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()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("label", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "address name"
|
||||
))
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "title"
|
||||
))
|
||||
->add("firstname", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "first name"
|
||||
))
|
||||
->add("lastname", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "last name"
|
||||
))
|
||||
->add("address1", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "address"
|
||||
))
|
||||
->add("address2", "text", array(
|
||||
"label" => "address (line 2)"
|
||||
))
|
||||
->add("address3", "text", array(
|
||||
"label" => "address (line 3)"
|
||||
))
|
||||
->add("zipcode", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "zipcode"
|
||||
))
|
||||
->add("city", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "city"
|
||||
))
|
||||
->add("country", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "country"
|
||||
))
|
||||
->add("phone", "text", array(
|
||||
"label" => "phone"
|
||||
))
|
||||
->add("cellphone", "text", array(
|
||||
"label" => "cellphone"
|
||||
))
|
||||
->add("company", "text", array(
|
||||
"label" => "company"
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_address_creation";
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,15 @@ class CouponCreationForm extends BaseForm
|
||||
new NotBlank()
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'locale',
|
||||
'hidden',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,20 +31,20 @@ class CurrencyCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$name_constraints = array(new Constraints\NotBlank());
|
||||
$code_constraints = array(new Constraints\NotBlank());
|
||||
|
||||
if (!$change_mode) {
|
||||
$name_constraints[] = new Constraints\Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateName"))
|
||||
$code_constraints[] = new Constraints\Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateCode"))
|
||||
));
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("name" , "text" , array("constraints" => array($name_constraints)))
|
||||
->add("locale" , "text" , array())
|
||||
->add("name" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("locale" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("symbol" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("rate" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("code" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("code" , "text" , array("constraints" => $code_constraints))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ class CurrencyCreationForm extends BaseForm
|
||||
return "thelia_currency_creation";
|
||||
}
|
||||
|
||||
public function checkDuplicateName($value, ExecutionContextInterface $context)
|
||||
public function checkDuplicateCode($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$currency = CurrencyQuery::create()->findOneByName($value);
|
||||
$currency = CurrencyQuery::create()->findOneByCode($value);
|
||||
|
||||
if ($currency) {
|
||||
$context->addViolation(sprintf("A currency with name \"%s\" already exists.", $value));
|
||||
$context->addViolation(sprintf("A currency with code \"%s\" already exists.", $value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ class CurrencyModificationForm extends CurrencyCreationForm
|
||||
parent::buildForm(true);
|
||||
|
||||
$this->formBuilder
|
||||
->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
;
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
Reference in New Issue
Block a user