aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Form
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Form')
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php39
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/ConfigType.php41
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryType.php29
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/NewUserType.php40
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/UserType.php31
5 files changed, 180 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php
new file mode 100644
index 00000000..e141789f
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/ChangePasswordType.php
@@ -0,0 +1,39 @@
1<?php
2namespace Wallabag\CoreBundle\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\FormBuilderInterface;
6use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
7use Symfony\Component\Validator\Constraints;
8
9class ChangePasswordType extends AbstractType
10{
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder
14 ->add('old_password', 'password', array(
15 'constraints' => new UserPassword(array('message' => 'Wrong value for your current password')),
16 ))
17 ->add('new_password', 'repeated', array(
18 'type' => 'password',
19 'invalid_message' => 'The password fields must match.',
20 'required' => true,
21 'first_options' => array('label' => 'New password'),
22 'second_options' => array('label' => 'Repeat new password'),
23 'constraints' => array(
24 new Constraints\Length(array(
25 'min' => 8,
26 'minMessage' => 'Password should by at least 8 chars long',
27 )),
28 new Constraints\NotBlank(),
29 ),
30 ))
31 ->add('save', 'submit')
32 ;
33 }
34
35 public function getName()
36 {
37 return 'change_passwd';
38 }
39}
diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php
new file mode 100644
index 00000000..a1e0ce47
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php
@@ -0,0 +1,41 @@
1<?php
2namespace Wallabag\CoreBundle\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\FormBuilderInterface;
6use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7
8class ConfigType extends AbstractType
9{
10 public function buildForm(FormBuilderInterface $builder, array $options)
11 {
12 $builder
13 ->add('theme', 'choice', array(
14 'choices' => array(
15 'baggy' => 'Baggy',
16 'courgette' => 'Courgette',
17 'dark' => 'Dark',
18 'default' => 'Default',
19 'dmagenta' => 'Dmagenta',
20 'solarized' => 'Solarized',
21 'solarized_dark' => 'Solarized Dark',
22 ),
23 ))
24 ->add('items_per_page', 'text')
25 ->add('language')
26 ->add('save', 'submit')
27 ;
28 }
29
30 public function setDefaultOptions(OptionsResolverInterface $resolver)
31 {
32 $resolver->setDefaults(array(
33 'data_class' => 'Wallabag\CoreBundle\Entity\Config',
34 ));
35 }
36
37 public function getName()
38 {
39 return 'config';
40 }
41}
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryType.php b/src/Wallabag/CoreBundle/Form/Type/EntryType.php
new file mode 100644
index 00000000..cfd64473
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/EntryType.php
@@ -0,0 +1,29 @@
1<?php
2namespace Wallabag\CoreBundle\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\FormBuilderInterface;
6use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7
8class EntryType extends AbstractType
9{
10 public function buildForm(FormBuilderInterface $builder, array $options)
11 {
12 $builder
13 ->add('url', 'url')
14 ->add('save', 'submit')
15 ;
16 }
17
18 public function setDefaultOptions(OptionsResolverInterface $resolver)
19 {
20 $resolver->setDefaults(array(
21 'data_class' => 'Wallabag\CoreBundle\Entity\Entry',
22 ));
23 }
24
25 public function getName()
26 {
27 return 'entry';
28 }
29}
diff --git a/src/Wallabag/CoreBundle/Form/Type/NewUserType.php b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
new file mode 100644
index 00000000..313a9aae
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/NewUserType.php
@@ -0,0 +1,40 @@
1<?php
2namespace Wallabag\CoreBundle\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\FormBuilderInterface;
6use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7use Symfony\Component\Validator\Constraints;
8
9class NewUserType extends AbstractType
10{
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder
14 ->add('username', 'text')
15 ->add('password', 'password', array(
16 'constraints' => array(
17 new Constraints\Length(array(
18 'min' => 8,
19 'minMessage' => 'Password should by at least 8 chars long',
20 )),
21 new Constraints\NotBlank(),
22 ),
23 ))
24 ->add('email', 'text')
25 ->add('save', 'submit')
26 ;
27 }
28
29 public function setDefaultOptions(OptionsResolverInterface $resolver)
30 {
31 $resolver->setDefaults(array(
32 'data_class' => 'Wallabag\CoreBundle\Entity\User',
33 ));
34 }
35
36 public function getName()
37 {
38 return 'new_user';
39 }
40}
diff --git a/src/Wallabag/CoreBundle/Form/Type/UserType.php b/src/Wallabag/CoreBundle/Form/Type/UserType.php
new file mode 100644
index 00000000..b479a0b5
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/UserType.php
@@ -0,0 +1,31 @@
1<?php
2namespace Wallabag\CoreBundle\Form\Type;
3
4use Symfony\Component\Form\AbstractType;
5use Symfony\Component\Form\FormBuilderInterface;
6use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7
8class UserType extends AbstractType
9{
10 public function buildForm(FormBuilderInterface $builder, array $options)
11 {
12 $builder
13 ->add('username', 'text')
14 ->add('name', 'text')
15 ->add('email', 'text')
16 ->add('save', 'submit')
17 ;
18 }
19
20 public function setDefaultOptions(OptionsResolverInterface $resolver)
21 {
22 $resolver->setDefaults(array(
23 'data_class' => 'Wallabag\CoreBundle\Entity\User',
24 ));
25 }
26
27 public function getName()
28 {
29 return 'user';
30 }
31}