Rajout du code core qui n'était pas gitté

This commit is contained in:
2020-05-08 20:00:41 +02:00
parent 4821ab2b5e
commit 096d58ea33
1654 changed files with 615177 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class MessageSendSampleForm extends BaseForm
{
public function getName()
{
return "thelia_message_send_sample";
}
protected function buildForm()
{
$this->formBuilder
->add(
"recipient_email",
"email",
[
"constraints" => array(new NotBlank()),
"label" => Translator::getInstance()->trans('Send test e-mail to:'),
"attr" => [
'placeholder' => Translator::getInstance()->trans('Recipient e-mail address')
]
]
);
;
}
}

View File

@@ -0,0 +1,157 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Form\OrderStatus;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
use Thelia\Form\StandardDescriptionFieldsTrait;
use Thelia\Model\Lang;
use Thelia\Model\OrderStatusQuery;
/**
* Class OrderStatusCreationForm
* @package Thelia\Form\OrderStatus
* @author Gilles Bourgeat <gbourgeat@openstudio.fr>
* @since 2.4
*/
class OrderStatusCreationForm extends BaseForm
{
use StandardDescriptionFieldsTrait;
protected function buildForm()
{
$this->formBuilder
->add(
'title',
'text',
[
'constraints' => [ new NotBlank() ],
'required' => true,
'label' => Translator::getInstance()->trans('Order status name'),
'label_attr' => [
'for' => 'title',
'help' => Translator::getInstance()->trans(
'Enter here the order status name in the default language (%title%)',
[ '%title%' => Lang::getDefaultLanguage()->getTitle()]
),
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('The order status name or title'),
]
]
)
->add(
'code',
'text',
[
'constraints' => [
new Callback([
'methods' => [
[$this, 'checkUniqueCode'],
[$this, 'checkFormatCode'],
[$this, 'checkIsRequiredCode']
]
])
],
'required' => true,
'label' => Translator::getInstance()->trans('Order status code'),
'label_attr' => [
'for' => 'title',
'help' => Translator::getInstance()->trans('Enter here the order status code'),
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('The order status code'),
]
]
)
->add(
'color',
'text',
[
'constraints' => [
new NotBlank(),
new Callback([
'methods' => [[$this, 'checkColor']]
])
],
'required' => false,
'label' => Translator::getInstance()->trans('Order status color'),
'label_attr' => [
'for' => 'title',
'help' => Translator::getInstance()->trans('Choice a color for this order status code'),
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('#000000'),
]
]
);
$this->addStandardDescFields(['title', 'description', 'chapo', 'postscriptum']);
}
public function getName()
{
return 'thelia_order_status_creation';
}
public function checkColor($value, ExecutionContextInterface $context)
{
if (!preg_match("/^#[0-9a-fA-F]{6}$/", $value)) {
$context->addViolation(
Translator::getInstance()->trans("This is not a hexadecimal color.")
);
}
}
public function checkUniqueCode($value, ExecutionContextInterface $context)
{
$query = OrderStatusQuery::create()
->filterByCode($value);
if ($this->form->has('id')) {
$query->filterById($this->form->get('id')->getData(), Criteria::NOT_EQUAL);
}
if ($query->findOne()) {
$context->addViolation(
Translator::getInstance()->trans("This code is already used.")
);
}
}
public function checkFormatCode($value, ExecutionContextInterface $context)
{
if (!empty($value) && !preg_match('/^\w+$/', $value)) {
$context->addViolation(
Translator::getInstance()->trans("This is not a valid code.")
);
}
}
public function checkIsRequiredCode($value, ExecutionContextInterface $context)
{
if ($this->form->has('id')) {
if (null !== $orderStatus = OrderStatusQuery::create()->findOneById($this->form->get('id')->getData())) {
if (!$orderStatus->getProtectedStatus() && empty($this->form->get('code')->getData())) {
$context->addViolation(
Translator::getInstance()->trans("This value should not be blank.")
);
}
}
}
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Form\OrderStatus;
use Symfony\Component\Validator\Constraints\GreaterThan;
/**
* Class OrderStatusModificationForm
* @package Thelia\Form\OrderStatus
* @author Gilles Bourgeat <gbourgeat@openstudio.fr>
* @since 2.4
*/
class OrderStatusModificationForm extends OrderStatusCreationForm
{
protected function buildForm()
{
$this->formBuilder->add("id", "hidden", [
'required' => true,
"constraints" => [
new GreaterThan(['value' => 0])
]
]);
parent::buildForm();
$this->addStandardDescFields();
}
public function getName()
{
return 'thelia_order_status_modification';
}
}