BooleanType.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. *
  10. */
  11. namespace Sonata\AdminBundle\Form\Type;
  12. use Symfony\Component\Form\AbstractType;
  13. use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  14. class BooleanType extends AbstractType
  15. {
  16. const TYPE_YES = 1;
  17. const TYPE_NO = 2;
  18. /**
  19. * {@inheritDoc}
  20. */
  21. public function setDefaultOptions(OptionsResolverInterface $resolver)
  22. {
  23. $resolver->setDefaults(array(
  24. 'catalogue' => 'SonataAdminBundle',
  25. 'choices' => array(
  26. self::TYPE_YES => 'label_type_yes',
  27. self::TYPE_NO => 'label_type_no'
  28. )
  29. ));
  30. }
  31. /**
  32. * {@inheritDoc}
  33. */
  34. public function getParent()
  35. {
  36. return 'sonata_type_translatable_choice';
  37. }
  38. /**
  39. * {@inheritDoc}
  40. */
  41. public function getName()
  42. {
  43. return 'sonata_type_boolean';
  44. }
  45. }