diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-10-02 15:00:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-02 15:00:02 +0200 |
commit | 1dc3bee6b916b228c596a45d20dc6ae14ac555cb (patch) | |
tree | 2d3573ebc6e6fbd71dd63f15653f3347cde8164e /src/Wallabag/UserBundle/Form | |
parent | 18b8dc0e9984fce01b231810347fef7d32c06ac7 (diff) | |
parent | ccc7faec094387681a59faa5ca79a86e33f06972 (diff) | |
download | wallabag-1dc3bee6b916b228c596a45d20dc6ae14ac555cb.tar.gz wallabag-1dc3bee6b916b228c596a45d20dc6ae14ac555cb.tar.zst wallabag-1dc3bee6b916b228c596a45d20dc6ae14ac555cb.zip |
Merge pull request #2327 from wallabag/user-management
Add users management UI
Diffstat (limited to 'src/Wallabag/UserBundle/Form')
-rw-r--r-- | src/Wallabag/UserBundle/Form/NewUserType.php | 58 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Form/UserType.php | 61 |
2 files changed, 119 insertions, 0 deletions
diff --git a/src/Wallabag/UserBundle/Form/NewUserType.php b/src/Wallabag/UserBundle/Form/NewUserType.php new file mode 100644 index 00000000..ad5a2405 --- /dev/null +++ b/src/Wallabag/UserBundle/Form/NewUserType.php | |||
@@ -0,0 +1,58 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\UserBundle\Form; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||
7 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||
8 | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | ||
9 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
10 | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
11 | use Symfony\Component\Form\FormBuilderInterface; | ||
12 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
13 | use Symfony\Component\Validator\Constraints; | ||
14 | |||
15 | class NewUserType extends AbstractType | ||
16 | { | ||
17 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
18 | { | ||
19 | $builder | ||
20 | ->add('username', TextType::class, [ | ||
21 | 'required' => true, | ||
22 | 'label' => 'user.form.username_label', | ||
23 | ]) | ||
24 | ->add('plainPassword', RepeatedType::class, [ | ||
25 | 'type' => PasswordType::class, | ||
26 | 'invalid_message' => 'validator.password_must_match', | ||
27 | 'first_options' => ['label' => 'user.form.password_label'], | ||
28 | 'second_options' => ['label' => 'user.form.repeat_new_password_label'], | ||
29 | 'constraints' => [ | ||
30 | new Constraints\Length([ | ||
31 | 'min' => 8, | ||
32 | 'minMessage' => 'validator.password_too_short', | ||
33 | ]), | ||
34 | new Constraints\NotBlank(), | ||
35 | ], | ||
36 | 'label' => 'user.form.plain_password_label', | ||
37 | ]) | ||
38 | ->add('email', EmailType::class, [ | ||
39 | 'label' => 'user.form.email_label', | ||
40 | ]) | ||
41 | ->add('save', SubmitType::class, [ | ||
42 | 'label' => 'user.form.save', | ||
43 | ]) | ||
44 | ; | ||
45 | } | ||
46 | |||
47 | public function configureOptions(OptionsResolver $resolver) | ||
48 | { | ||
49 | $resolver->setDefaults([ | ||
50 | 'data_class' => 'Wallabag\UserBundle\Entity\User', | ||
51 | ]); | ||
52 | } | ||
53 | |||
54 | public function getBlockPrefix() | ||
55 | { | ||
56 | return 'new_user'; | ||
57 | } | ||
58 | } | ||
diff --git a/src/Wallabag/UserBundle/Form/UserType.php b/src/Wallabag/UserBundle/Form/UserType.php new file mode 100644 index 00000000..cfa67793 --- /dev/null +++ b/src/Wallabag/UserBundle/Form/UserType.php | |||
@@ -0,0 +1,61 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\UserBundle\Form; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\FormBuilderInterface; | ||
7 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
8 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | ||
9 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
10 | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
11 | use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||
12 | |||
13 | class UserType extends AbstractType | ||
14 | { | ||
15 | /** | ||
16 | * @param FormBuilderInterface $builder | ||
17 | * @param array $options | ||
18 | */ | ||
19 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
20 | { | ||
21 | $builder | ||
22 | ->add('name', TextType::class, [ | ||
23 | 'required' => false, | ||
24 | 'label' => 'user.form.name_label', | ||
25 | ]) | ||
26 | ->add('username', TextType::class, [ | ||
27 | 'required' => true, | ||
28 | 'label' => 'user.form.username_label', | ||
29 | ]) | ||
30 | ->add('email', EmailType::class, [ | ||
31 | 'required' => true, | ||
32 | 'label' => 'user.form.email_label', | ||
33 | ]) | ||
34 | ->add('enabled', CheckboxType::class, [ | ||
35 | 'required' => false, | ||
36 | 'label' => 'user.form.enabled_label', | ||
37 | ]) | ||
38 | ->add('locked', CheckboxType::class, [ | ||
39 | 'required' => false, | ||
40 | 'label' => 'user.form.locked_label', | ||
41 | ]) | ||
42 | ->add('twoFactorAuthentication', CheckboxType::class, [ | ||
43 | 'required' => false, | ||
44 | 'label' => 'user.form.twofactor_label', | ||
45 | ]) | ||
46 | ->add('save', SubmitType::class, [ | ||
47 | 'label' => 'user.form.save', | ||
48 | ]) | ||
49 | ; | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * @param OptionsResolver $resolver | ||
54 | */ | ||
55 | public function configureOptions(OptionsResolver $resolver) | ||
56 | { | ||
57 | $resolver->setDefaults(array( | ||
58 | 'data_class' => 'Wallabag\UserBundle\Entity\User', | ||
59 | )); | ||
60 | } | ||
61 | } | ||