src/Eccube/Form/Type/ToggleSwitchType.php line 22

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Form\Type;
  13. use Symfony\Component\Form\AbstractType;
  14. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  15. use Symfony\Component\Form\FormInterface;
  16. use Symfony\Component\Form\FormView;
  17. use Symfony\Component\OptionsResolver\OptionsResolver;
  18. class ToggleSwitchType extends AbstractType
  19. {
  20.     public function buildView(FormView $viewFormInterface $form, array $options)
  21.     {
  22.         $view->vars['label_on'] = $options['label_on'];
  23.         $view->vars['label_off'] = $options['label_off'];
  24.     }
  25.     public function configureOptions(OptionsResolver $resolver)
  26.     {
  27.         $resolver->setDefaults([
  28.             'label' => false,
  29.             'label_on' => 'common.enabled',
  30.             'label_off' => 'common.disabled',
  31.         ]);
  32.     }
  33.     public function getParent()
  34.     {
  35.         return CheckboxType::class;
  36.     }
  37. }