Merge branch 'master' of https://github.com/thelia/thelia into coupon

* 'master' of https://github.com/thelia/thelia: (33 commits)
  permissions
  finish contact process
  create contact form
  create example for mail usage
  permission cleanup
  change place where absolute url is create when rewritten url is enabled
  fix issue #43
  fix typo in product breadcrumb
  update countries list
  fix issue #35
  fix cartItem updateQuantity method
  add some verification on country default trigger
  not allowed to delete default country
  WIP : admin profiles
  fiw test suite
  clear cache when a module is removed
  end module removal
  create event object for module delete action
  update insert script
  new model
  ...

Conflicts:
	core/lib/Thelia/Controller/Admin/CouponController.php
This commit is contained in:
gmorel
2013-10-22 23:01:04 +02:00
128 changed files with 4095 additions and 1209 deletions

View File

@@ -0,0 +1,98 @@
<?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\Callback;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Model\NewsletterQuery;
/**
* Class NewsletterForm
* @package Thelia\Form
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class NewsletterForm 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('email', 'email', array(
'constraints' => array(
new NotBlank(),
new Email(),
new Callback(array(
"methods" => array(
array($this,
"verifyExistingEmail")
)
))
),
'label' => Translator::getInstance()->trans('email'),
'label_attr' => array(
'for' => 'email_newsletter'
)
));
}
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = NewsletterQuery::create()->findOneByEmail($value);
if ($customer) {
$context->addViolation("This email already exists");
}
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'thelia_newsletter';
}
}