]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/ApiBundle/Form/Type/ClientType.php
Add a real configuration for CS-Fixer
[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',
23 ])
4094ea47 24 ->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label'])
abc32945
NL
25 ;
26
27 $builder->get('redirect_uris')
28 ->addModelTransformer(new CallbackTransformer(
29 function ($originalUri) {
30 return $originalUri;
31 },
32 function ($submittedUri) {
4094ea47 33 return [$submittedUri];
abc32945
NL
34 }
35 ))
36 ;
37 }
38
39 public function configureOptions(OptionsResolver $resolver)
40 {
4094ea47 41 $resolver->setDefaults([
abc32945 42 'data_class' => 'Wallabag\ApiBundle\Entity\Client',
4094ea47 43 ]);
abc32945
NL
44 }
45
46 public function getBlockPrefix()
47 {
48 return 'client';
49 }
50}