123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- /*
- * This file is part of the Sonata package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Sonata\AdminBundle\Form\Extension;
- use Symfony\Component\Form\AbstractTypeExtension;
- use Symfony\Component\Form\FormView;
- use Symfony\Component\Form\FormInterface;
- use Symfony\Component\OptionsResolver\OptionsResolverInterface;
- /**
- * Class ChoiceTypeExtension
- *
- * @package Sonata\AdminBundle\Form\Extension
- *
- * @author Amine Zaghdoudi <amine.zaghdoudi@ekino.com>
- */
- class ChoiceTypeExtension extends AbstractTypeExtension
- {
- /**
- * {@inheritdoc}
- */
- public function setDefaultOptions(OptionsResolverInterface $resolver)
- {
- $optionalOptions = array('sortable');
- if (method_exists($resolver, 'setDefined')) {
- $resolver->setDefined($optionalOptions);
- } else {
- // To keep Symfony <2.6 support
- $resolver->setOptional($optionalOptions);
- }
- }
- /**
- * {@inheritdoc}
- */
- public function buildView(FormView $view, FormInterface $form, array $options)
- {
- $view->vars['sortable'] = array_key_exists('sortable', $options) && $options['sortable'];
- }
- /**
- * Returns the name of the type being extended.
- *
- * @return string The name of the type being extended
- */
- public function getExtendedType()
- {
- return 'choice';
- }
- }
|