src/Eccube/Form/Type/Admin/OrderMailType.php line 53

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Form\Type\Admin;
  13. use Doctrine\ORM\EntityRepository;
  14. use Eccube\Common\EccubeConfig;
  15. use Eccube\Form\Type\Master\MailTemplateType;
  16. use Eccube\Form\Validator\TwigLint;
  17. use Symfony\Component\Form\AbstractType;
  18. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  19. use Symfony\Component\Form\Extension\Core\Type\TextType;
  20. use Symfony\Component\Form\FormBuilderInterface;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. class OrderMailType extends AbstractType
  23. {
  24.     /**
  25.      * @var EccubeConfig
  26.      */
  27.     protected $eccubeConfig;
  28.     /**
  29.      * MailType constructor.
  30.      *
  31.      * @param EccubeConfig $eccubeConfig
  32.      */
  33.     public function __construct(
  34.         EccubeConfig $eccubeConfig
  35.     ) {
  36.         $this->eccubeConfig $eccubeConfig;
  37.     }
  38.     /**
  39.      * {@inheritdoc}
  40.      */
  41.     public function buildForm(FormBuilderInterface $builder, array $options)
  42.     {
  43.         $builder
  44.             ->add('template'MailTemplateType::class, [
  45.                 'required' => false,
  46.                 'mapped' => false,
  47.                 'query_builder' => function (EntityRepository $er) {
  48.                     return $er->createQueryBuilder('mt')
  49.                         ->andWhere('mt.id = :id')
  50.                         ->setParameter('id'$this->eccubeConfig['eccube_order_mail_template_id'])
  51.                         ->orderBy('mt.id''ASC');
  52.                 },
  53.             ])
  54.             ->add('mail_subject'TextType::class, [
  55.                 'required' => true,
  56.                 'constraints' => [
  57.                     new Assert\NotBlank(),
  58.                 ],
  59.             ])
  60.             ->add('tpl_data'TextareaType::class, [
  61.                 'label' => false,
  62.                 'mapped' => false,
  63.                 'required' => false,
  64.                 'constraints' => [
  65.                     new TwigLint(),
  66.                 ],
  67.             ])
  68.         ;
  69.     }
  70.     /**
  71.      * {@inheritdoc}
  72.      */
  73.     public function getBlockPrefix()
  74.     {
  75.         return 'admin_order_mail';
  76.     }
  77. }