propel-bundle/Form/Type/TranslationType.php

61 lines
1.3 KiB
PHP
Raw Normal View History

2013-12-12 16:01:41 +01:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2016-02-11 19:14:03 +01:00
namespace Propel\Bundle\PropelBundle\Form\Type;
2013-12-12 16:01:41 +01:00
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
2015-08-06 19:02:55 +02:00
use Symfony\Component\OptionsResolver\OptionsResolver;
2016-02-11 19:14:03 +01:00
use Propel\Bundle\PropelBundle\Form\EventListener\TranslationFormListener;
2015-08-06 19:02:55 +02:00
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
2013-12-12 16:01:41 +01:00
/**
* Translation type class
*
* @author Patrick Kaufmann
*/
class TranslationType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(
new TranslationFormListener($options['columns'], $options['data_class'])
);
}
/**
* {@inheritdoc}
*/
2016-02-11 21:33:19 +01:00
public function configureOptions(OptionsResolver $resolver)
2013-12-12 16:01:41 +01:00
{
2016-02-11 21:33:19 +01:00
$resolver->setRequired(array(
'data_class',
'columns'
));
2013-12-12 16:01:41 +01:00
}
/**
* {@inheritdoc}
*/
2016-02-11 21:33:19 +01:00
public function getBlockPrefix()
2013-12-12 16:01:41 +01:00
{
2016-02-11 21:33:19 +01:00
return 'propel_translation';
2013-12-12 16:01:41 +01:00
}
2015-08-06 19:02:55 +02:00
2016-02-11 21:33:19 +01:00
public function getName()
2015-08-06 19:02:55 +02:00
{
2016-02-11 21:33:19 +01:00
return $this->getBlockPrefix();
2015-08-06 19:02:55 +02:00
}
2013-12-12 16:01:41 +01:00
}