Initial commit

This commit is contained in:
2020-01-27 08:56:08 +01:00
commit b7525048d6
27129 changed files with 3409855 additions and 0 deletions

View File

@@ -0,0 +1,189 @@
<?php
/**
* This class has been generated by TheliaStudio
* For more information, see https://github.com/thelia-modules/TheliaStudio
*/
namespace SupportTicket\Form\Base;
use SupportTicket\SupportTicket;
use Thelia\Form\BaseForm;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* Class SupportTicketCreateForm
* @package SupportTicket\Form\Base
* @author TheliaStudio
*/
class SupportTicketCreateForm extends BaseForm
{
const FORM_NAME = "support_ticket_create";
public function buildForm()
{
$translationKeys = $this->getTranslationKeys();
$fieldsIdKeys = $this->getFieldsIdKeys();
$this->addStatusField($translationKeys, $fieldsIdKeys);
$this->addCustomerIdField($translationKeys, $fieldsIdKeys);
$this->addAdminIdField($translationKeys, $fieldsIdKeys);
$this->addOrderIdField($translationKeys, $fieldsIdKeys);
$this->addOrderProductIdField($translationKeys, $fieldsIdKeys);
$this->addSubjectField($translationKeys, $fieldsIdKeys);
$this->addMessageField($translationKeys, $fieldsIdKeys);
$this->addResponseField($translationKeys, $fieldsIdKeys);
$this->addCommentField($translationKeys, $fieldsIdKeys);
}
protected function addStatusField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("status", "checkbox", array(
"label" => $this->translator->trans($this->readKey("status", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("status", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
protected function addCustomerIdField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("customer_id", "integer", array(
"label" => $this->translator->trans($this->readKey("customer_id", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("customer_id", $fieldsIdKeys)],
"required" => true,
"constraints" => array(
new NotBlank(),
),
"attr" => array(
)
));
}
protected function addAdminIdField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("admin_id", "integer", array(
"label" => $this->translator->trans($this->readKey("admin_id", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("admin_id", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
protected function addOrderIdField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("order_id", "integer", array(
"label" => $this->translator->trans($this->readKey("order_id", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("order_id", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
protected function addOrderProductIdField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("order_product_id", "integer", array(
"label" => $this->translator->trans($this->readKey("order_product_id", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("order_product_id", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
protected function addSubjectField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("subject", "text", array(
"label" => $this->translator->trans($this->readKey("subject", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("subject", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
protected function addMessageField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("message", "textarea", array(
"label" => $this->translator->trans($this->readKey("message", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("message", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
protected function addResponseField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("response", "textarea", array(
"label" => $this->translator->trans($this->readKey("response", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("response", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
protected function addCommentField(array $translationKeys, array $fieldsIdKeys)
{
$this->formBuilder->add("comment", "textarea", array(
"label" => $this->translator->trans($this->readKey("comment", $translationKeys), [], SupportTicket::MESSAGE_DOMAIN),
"label_attr" => ["for" => $this->readKey("comment", $fieldsIdKeys)],
"required" => false,
"constraints" => array(
),
"attr" => array(
)
));
}
public function getName()
{
return static::FORM_NAME;
}
public function readKey($key, array $keys, $default = '')
{
if (isset($keys[$key])) {
return $keys[$key];
}
return $default;
}
public function getTranslationKeys()
{
return array();
}
public function getFieldsIdKeys()
{
return array(
"status" => "support_ticket_status",
"customer_id" => "support_ticket_customer_id",
"admin_id" => "support_ticket_admin_id",
"order_id" => "support_ticket_order_id",
"order_product_id" => "support_ticket_order_product_id",
"subject" => "support_ticket_subject",
"message" => "support_ticket_message",
"response" => "support_ticket_response",
"comment" => "support_ticket_comment",
);
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* This class has been generated by TheliaStudio
* For more information, see https://github.com/thelia-modules/TheliaStudio
*/
namespace SupportTicket\Form\Base;
use SupportTicket\Form\SupportTicketCreateForm as ChildSupportTicketCreateForm;
use SupportTicket\Form\Type\SupportTicketIdType;
/**
* Class SupportTicketForm
* @package SupportTicket\Form
* @author TheliaStudio
*/
class SupportTicketUpdateForm extends ChildSupportTicketCreateForm
{
const FORM_NAME = "support_ticket_update";
public function buildForm()
{
parent::buildForm();
$this->formBuilder
->add("id", SupportTicketIdType::TYPE_NAME)
;
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<dwsync>
<file name="SupportTicketCreateForm.php" server="51.254.220.106//web/" local="131351950200000000" remote="131351950200000000" />
<file name="SupportTicketUpdateForm.php" server="51.254.220.106//web/" local="131351950200000000" remote="131351950200000000" />
</dwsync>

View File

@@ -0,0 +1,31 @@
<?php
/**
* This class has been generated by TheliaStudio
* For more information, see https://github.com/thelia-modules/TheliaStudio
*/
namespace SupportTicket\Form;
use SupportTicket\Form\Base\SupportTicketCreateForm as BaseSupportTicketCreateForm;
/**
* Class SupportTicketCreateForm
* @package SupportTicket\Form
*/
class SupportTicketCreateForm extends BaseSupportTicketCreateForm
{
public function getTranslationKeys()
{
return array(
"status" => "Status", // ->trans("Status")
"customer_id" => "Customer id", // ->trans("Customer id")
"admin_id" => "Admin id", // ->trans("Admin id")
"order_id" => "Order id", // ->trans("Order id")
"order_product_id" => "Order product id", // ->trans("Order product id")
"subject" => "Subject", // ->trans("Subject")
"message" => "Message", // ->trans("Message")
"response" => "Response", // ->trans("Response")
"comment" => "Comment", // ->trans("Comment")
);
}
}

View File

@@ -0,0 +1,150 @@
<?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 SupportTicket\Form;
use SupportTicket\SupportTicket;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
use Thelia\Model\OrderProductQuery;
use Thelia\Model\OrderQuery;
/**
* Class SupportTicketFrontCreateForm
* @package SupportTicket\Form
* @author Julien Chanséaume <julien@thelia.net>
*/
class SupportTicketFrontCreateForm extends BaseForm
{
/** @var Translator $translator */
protected $translator;
public function verifyOrder($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if (!empty($data["order_id"])) {
$order = OrderQuery::create()->findPk($data["order_id"]);
if (null === $order || !$order->isPaid() || $order->getCustomerId() != $data["customer_id"]) {
$context->addViolation(
$this->trans("The order is not a valid order")
);
} else {
if (!empty($data["order_product_id"])) {
$orderProduct = OrderProductQuery::create()->findPk($data["order_product_id"]);
if (null === $order || $orderProduct->getOrderId() !== $order->getId()) {
$context->addViolation(
$this->trans("The product is not a valid product")
);
}
}
}
}
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "supportticket_new";
}
/**
*
* 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(
"customer_id",
'text',
[
"constraints" => [
new NotBlank(),
new Callback(
[
"methods" => [
[$this, "verifyOrder"],
]
]
)
]
]
)
->add(
"order_id",
'text',
[
"label" => $this->trans("Order"),
]
)
->add(
"order_product_id",
'text',
[
"label" => $this->trans("Product"),
]
)
->add(
"subject",
'text',
[
"label" => $this->trans("Subject"),
"constraints" => [
new NotBlank()
]
]
)
->add(
"message",
'textarea',
[
"label" => $this->trans("Message"),
"constraints" => [
new NotBlank()
]
]
);
}
protected function trans($id, $parameters = [])
{
if (null === $this->translator) {
$this->translator = Translator::getInstance();
}
return $this->translator->trans($id, $parameters, SupportTicket::MESSAGE_DOMAIN);
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* This class has been generated by TheliaStudio
* For more information, see https://github.com/thelia-modules/TheliaStudio
*/
namespace SupportTicket\Form;
use SupportTicket\Form\Base\SupportTicketUpdateForm as BaseSupportTicketUpdateForm;
/**
* Class SupportTicketUpdateForm
* @package SupportTicket\Form
*/
class SupportTicketUpdateForm extends BaseSupportTicketUpdateForm
{
public function getTranslationKeys()
{
return array(
"id" => "id", // ->trans("Id")
"status" => "Status", // ->trans("Status")
"customer_id" => "Customer id", // ->trans("Customer id")
"admin_id" => "Admin id", // ->trans("Admin id")
"order_id" => "Order id", // ->trans("Order id")
"order_product_id" => "Order product id", // ->trans("Order product id")
"subject" => "Subject", // ->trans("Subject")
"message" => "Message", // ->trans("Message")
"response" => "Response", // ->trans("Response")
"comment" => "Comment", // ->trans("Comment")
);
}
public function buildForm()
{
parent::buildForm();
$this->formBuilder
->remove("customer_id")
->remove("order_id")
->remove("order_product_id")
->remove("status");
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* This class has been generated by TheliaStudio
* For more information, see https://github.com/thelia-modules/TheliaStudio
*/
namespace SupportTicket\Form\Type\Base;
use Thelia\Core\Form\Type\Field\AbstractIdType;
use SupportTicket\Model\SupportTicketQuery;
/**
* Class SupportTicket
* @package SupportTicket\Form\Base
* @author TheliaStudio
*/
class SupportTicketIdType extends AbstractIdType
{
const TYPE_NAME = "support_ticket_id";
protected function getQuery()
{
return new SupportTicketQuery();
}
public function getName()
{
return static::TYPE_NAME;
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<dwsync>
<file name="SupportTicketIdType.php" server="51.254.220.106//web/" local="131351950200000000" remote="131351950200000000" />
</dwsync>

View File

@@ -0,0 +1,17 @@
<?php
/**
* This class has been generated by TheliaStudio
* For more information, see https://github.com/thelia-modules/TheliaStudio
*/
namespace SupportTicket\Form\Type;
use SupportTicket\Form\Type\Base\SupportTicketIdType as BaseSupportTicketIdType;
/**
* Class SupportTicket
* @package SupportTicket\Form
*/
class SupportTicketIdType extends BaseSupportTicketIdType
{
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<dwsync>
<file name="SupportTicketIdType.php" server="51.254.220.106//web/" local="131351950200000000" remote="131351950200000000" />
</dwsync>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<dwsync>
<file name="SupportTicketCreateForm.php" server="51.254.220.106//web/" local="131351950200000000" remote="131351950200000000" />
<file name="SupportTicketFrontCreateForm.php" server="51.254.220.106//web/" local="131351950200000000" remote="131351950200000000" />
<file name="SupportTicketUpdateForm.php" server="51.254.220.106//web/" local="131351950200000000" remote="131351950200000000" />
</dwsync>