<?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\Master;
use Eccube\Form\Type\MasterType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class PrefType
*/
class PrefType extends AbstractType
{
private $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'class' => 'Eccube\Entity\Master\Pref',
'placeholder' => 'common.select__pref',
'choice_label' => function ($pref) {
// 翻訳キーを使用
return $this->translator->trans('pref.' . $pref->getId(), [], 'messages');
},
]);
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'pref';
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return MasterType::class;
}
}