Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (2) and franck (1) # Via franck * 'master' of https://github.com/thelia/thelia: Completed mailing templates management change symfony/icu version for compatibility add file reset_install.sh Conflicts: composer.json core/lib/Thelia/Config/Resources/config.xml core/lib/Thelia/Model/Map/CouponI18nTableMap.php install/thelia.sql local/config/schema.xml reset_install.sh
This commit is contained in:
73
core/lib/Thelia/Form/MessageCreationForm.php
Normal file
73
core/lib/Thelia/Form/MessageCreationForm.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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;
|
||||
use Thelia\Model\MessageQuery;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
|
||||
class MessageCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$name_constraints = array(new Constraints\NotBlank());
|
||||
|
||||
if (!$change_mode) {
|
||||
$name_constraints[] = new Constraints\Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateName"))
|
||||
));
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("name", "text", array(
|
||||
"constraints" => $name_constraints
|
||||
))
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank()
|
||||
)
|
||||
))
|
||||
->add("locale", "hidden", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank()
|
||||
)
|
||||
))
|
||||
->add("secured", "hidden", array())
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_message_creation";
|
||||
}
|
||||
|
||||
public function checkDuplicateName($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$message = MessageQuery::create()->findOneByName($value);
|
||||
|
||||
if ($message) {
|
||||
$context->addViolation(sprintf("A message with name \"%s\" already exists.", $value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
50
core/lib/Thelia/Form/MessageModificationForm.php
Normal file
50
core/lib/Thelia/Form/MessageModificationForm.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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;
|
||||
use Thelia\Model\LangQuery;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
|
||||
class MessageModificationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
->add("name" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("secured" , "text" , array())
|
||||
->add("locale" , "text" , array())
|
||||
->add("title" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("subject" , "text" , array("constraints" => array(new NotBlank())))
|
||||
->add("html_message" , "text" , array())
|
||||
->add("text_message" , "text" , array())
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_message_modification";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user