]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Form/Type/ClientType.php
Added name on client
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Form / Type / ClientType.php
CommitLineData
abc32945
NL
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\CallbackTransformer;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8use Symfony\Component\Form\Extension\Core\Type\UrlType;
9c545fe0 9use Symfony\Component\Form\Extension\Core\Type\TextType;
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
TC
18 ->add('name', TextType::class, ['label' => 'developer.client.form.name_label'])
19 ->add('redirect_uris', UrlType::class, ['required' => false, 'label' => 'developer.client.form.redirect_uris_label'])
4094ea47 20 ->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label'])
abc32945
NL
21 ;
22
23 $builder->get('redirect_uris')
24 ->addModelTransformer(new CallbackTransformer(
25 function ($originalUri) {
26 return $originalUri;
27 },
28 function ($submittedUri) {
4094ea47 29 return [$submittedUri];
abc32945
NL
30 }
31 ))
32 ;
33 }
34
35 public function configureOptions(OptionsResolver $resolver)
36 {
4094ea47 37 $resolver->setDefaults([
abc32945 38 'data_class' => 'Wallabag\ApiBundle\Entity\Client',
4094ea47 39 ]);
abc32945
NL
40 }
41
42 public function getBlockPrefix()
43 {
44 return 'client';
45 }
46}