diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-08 00:02:22 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-08 00:05:41 +0200 |
commit | ee32248f43baef7e995c9e420cd00a137e626cf0 (patch) | |
tree | e8119e417887b3132bc7c448a7591943c90dcab2 /src/Wallabag/ApiBundle/Form | |
parent | b0da721a5238ece3056ae7af760e9455f7af3e11 (diff) | |
download | wallabag-ee32248f43baef7e995c9e420cd00a137e626cf0.tar.gz wallabag-ee32248f43baef7e995c9e420cd00a137e626cf0.tar.zst wallabag-ee32248f43baef7e995c9e420cd00a137e626cf0.zip |
Ensure access_token are removed
When we remove the client, we should ensure that access_token are also removed.
To ensure that, I created a test that generated an access_token. So when we remove the client, this association should be cascaded and shouldn’t generate an error.
Also I moved some Api related stuff to the ApiBundle (like the developer controler and ClientType form)
Diffstat (limited to 'src/Wallabag/ApiBundle/Form')
-rw-r--r-- | src/Wallabag/ApiBundle/Form/Type/ClientType.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Form/Type/ClientType.php b/src/Wallabag/ApiBundle/Form/Type/ClientType.php new file mode 100644 index 00000000..0ea1a9c5 --- /dev/null +++ b/src/Wallabag/ApiBundle/Form/Type/ClientType.php | |||
@@ -0,0 +1,46 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ApiBundle\Form\Type; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\CallbackTransformer; | ||
7 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
8 | use Symfony\Component\Form\Extension\Core\Type\UrlType; | ||
9 | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
10 | use Symfony\Component\Form\FormBuilderInterface; | ||
11 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
12 | |||
13 | class ClientType extends AbstractType | ||
14 | { | ||
15 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
16 | { | ||
17 | $builder | ||
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']) | ||
20 | ->add('save', SubmitType::class, ['label' => 'developer.client.form.save_label']) | ||
21 | ; | ||
22 | |||
23 | $builder->get('redirect_uris') | ||
24 | ->addModelTransformer(new CallbackTransformer( | ||
25 | function ($originalUri) { | ||
26 | return $originalUri; | ||
27 | }, | ||
28 | function ($submittedUri) { | ||
29 | return [$submittedUri]; | ||
30 | } | ||
31 | )) | ||
32 | ; | ||
33 | } | ||
34 | |||
35 | public function configureOptions(OptionsResolver $resolver) | ||
36 | { | ||
37 | $resolver->setDefaults([ | ||
38 | 'data_class' => 'Wallabag\ApiBundle\Entity\Client', | ||
39 | ]); | ||
40 | } | ||
41 | |||
42 | public function getBlockPrefix() | ||
43 | { | ||
44 | return 'client'; | ||
45 | } | ||
46 | } | ||