<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Form\Type\Admin;
use Doctrine\ORM\EntityRepository;
use Eccube\Common\EccubeConfig;
use Eccube\Form\Type\Master\MailTemplateType;
use Eccube\Form\Validator\TwigLint;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class OrderMailType extends AbstractType
{
/**
* @var EccubeConfig
*/
protected $eccubeConfig;
/**
* MailType constructor.
*
* @param EccubeConfig $eccubeConfig
*/
public function __construct(
EccubeConfig $eccubeConfig
) {
$this->eccubeConfig = $eccubeConfig;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('template', MailTemplateType::class, [
'required' => false,
'mapped' => false,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('mt')
->andWhere('mt.id = :id')
->setParameter('id', $this->eccubeConfig['eccube_order_mail_template_id'])
->orderBy('mt.id', 'ASC');
},
])
->add('mail_subject', TextType::class, [
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
])
->add('tpl_data', TextareaType::class, [
'label' => false,
'mapped' => false,
'required' => false,
'constraints' => [
new TwigLint(),
],
])
;
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'admin_order_mail';
}
}