]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/ApiBundle/Form/Type/ClientType.php
Merge pull request #4438 from wallabag/dependabot/composer/scheb/two-factor-bundle...
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Form / Type / ClientType.php
CommitLineData
abc32945
NL
1<?php
2
ee32248f 3namespace Wallabag\ApiBundle\Form\Type;
abc32945
NL
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\CallbackTransformer;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9c545fe0 8use Symfony\Component\Form\Extension\Core\Type\TextType;
f808b016 9use Symfony\Component\Form\Extension\Core\Type\UrlType;
abc32945
NL
10use Symfony\Component\Form\FormBuilderInterface;
11use Symfony\Component\OptionsResolver\OptionsResolver;
12
13class ClientType extends AbstractType
14{
15 public function buildForm(FormBuilderInterface $builder, array $options)
16 {
17 $builder
9c545fe0 18 ->add('name', TextType::class, ['label' => 'developer.client.form.name_label'])
ab9eb5cd 19 ->add('redirect_uris', UrlType::class, [
20 'required' => false,
21 'label' => 'developer.client.form.redirect_uris_label',
22 'property_path' => 'redirectUris',
baa5ee2d 23 'default_protocol' => null,
ab9eb5cd 24 ])
4094ea47 25 ->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label'])
abc32945
NL
26 ;
27
28 $builder->get('redirect_uris')
29 ->addModelTransformer(new CallbackTransformer(
30 function ($originalUri) {
31 return $originalUri;
32 },
33 function ($submittedUri) {
4094ea47 34 return [$submittedUri];
abc32945
NL
35 }
36 ))
37 ;
38 }
39
40 public function configureOptions(OptionsResolver $resolver)
41 {
4094ea47 42 $resolver->setDefaults([
abc32945 43 'data_class' => 'Wallabag\ApiBundle\Entity\Client',
4094ea47 44 ]);
abc32945
NL
45 }
46
47 public function getBlockPrefix()
48 {
49 return 'client';
50 }
51}