]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Form/Type/ClientType.php
Convert array + phpDoc
[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;
9use Symfony\Component\Form\FormBuilderInterface;
10use Symfony\Component\OptionsResolver\OptionsResolver;
11
12class ClientType extends AbstractType
13{
14 public function buildForm(FormBuilderInterface $builder, array $options)
15 {
16 $builder
4094ea47
JB
17 ->add('redirect_uris', UrlType::class, ['required' => true, 'label' => 'developer.client.form.redirect_uris_label'])
18 ->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label'])
abc32945
NL
19 ;
20
21 $builder->get('redirect_uris')
22 ->addModelTransformer(new CallbackTransformer(
23 function ($originalUri) {
24 return $originalUri;
25 },
26 function ($submittedUri) {
4094ea47 27 return [$submittedUri];
abc32945
NL
28 }
29 ))
30 ;
31 }
32
33 public function configureOptions(OptionsResolver $resolver)
34 {
4094ea47 35 $resolver->setDefaults([
abc32945 36 'data_class' => 'Wallabag\ApiBundle\Entity\Client',
4094ea47 37 ]);
abc32945
NL
38 }
39
40 public function getBlockPrefix()
41 {
42 return 'client';
43 }
44}