src/Form/VPN/Service/Service/UnlimitedV2rayType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form\VPN\Service\Service;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  5. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  6. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class UnlimitedV2rayType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('serviceType'HiddenType::class, [
  16.                 'data' => 'unlimited'
  17.             ])
  18.             ->add('protocol'HiddenType::class, [
  19.                 'data' => 'v2ray'
  20.             ])
  21.             ->add('username' null , [
  22.                 'label' => 'نام انتخابی سرویس'
  23.             ])
  24.             ->add('host' ChoiceType::class , [
  25.                 'label' => 'میزبانی سرویس',
  26.                 'choices' => [
  27.                     'سرور های تهران نت' => 'tehrannet',
  28.                     'سرور های خودم' => 'mine'
  29.                 ],
  30.                 'mapped' => false,
  31.                 'choice_attr' => function($choice$key$value) {
  32.                     if ($value !== 'tehrannet') {
  33.                         return ['disabled' => 'disabled'];
  34.                     }
  35.                     return [];
  36.                 },
  37.             ])
  38.             ->add('password' null , [
  39.                 'label'=>'کلمه عبور انتخابی'
  40.             ])
  41.             ->add('clientId'NumberType::class, [
  42.                 'data' => $options['clientId'],
  43.                 'disabled' => true,
  44.                 'label' => 'شناسه یکتا سرویس'
  45.             ])
  46.             ->add('users'ChoiceType::class, [
  47.                 'attr' => ['class' => 'ajax-v2rayUnLimited'],
  48.                 'label' => 'تعداد کاربر مورد نیاز',
  49.                 'choices' => [
  50.                     'یک کاربر' => 1,
  51.                     'دو کاربر' => 2,
  52.                     'سه کاربر' => 3,
  53.                     'چهار کاربر' => 4,
  54.                     'پنج کاربر' => 5,
  55. //                    'بدون محدودیت کاربر' => 0,
  56.                 ]
  57.             ])
  58.             ->add('size'HiddenType::class, [
  59.                 'data' => 0
  60.             ])
  61.             ->add('country' ChoiceType::class, [
  62.                 'attr' => ['class' => 'ajax-v2rayUnLimited'],
  63.                 'label' => 'کشور',
  64.                 'choices' => $options['locations'] ,
  65. //                'choices' => [
  66. //                    'تمام کشور های موجود' => 'all'
  67. //                ] ,
  68.                 'mapped' => false,
  69.                 'required'=> true
  70.             ])
  71.             ->add('days'ChoiceType::class, [
  72.                 'attr' => ['class' => 'ajax-v2rayUnLimited'],
  73.                 'label' => 'زمان مورد نیاز',
  74.                 'choices' => [
  75.                     'یک ماه' => 30,
  76. //                    'دو ماه' => 60,
  77. //                    'سه ماه' => 90,
  78. //                    'شش ماه' => 180,
  79. //                    'دوازده ماه' => 365,
  80.                 ]
  81.             ]) ->add('price' TextType::class , [
  82.                 'label' => 'هزینه بسته انتخابی',
  83.                 'disabled' => true ,
  84.                 'mapped' => false,
  85.                 'data' => 'ابتدا موارد بالا را انتخاب فرمایید',
  86.                 'attr' => ['class' => 'form-control text-warning border-warning']
  87.             ]);
  88.     }
  89.     public function configureOptions(OptionsResolver $resolver): void
  90.     {
  91.         $resolver->setDefaults([
  92.             'clientId' => null,
  93.             'locations' => []
  94.         ]);
  95.     }
  96. }