diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-10-23 11:09:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 11:09:17 +0200 |
commit | 1953a872932a63792293b4aec087880265ba89f7 (patch) | |
tree | fd16599e737fcdaf193c933ef3ec4a4ee248b117 /src/Wallabag/CoreBundle/Form | |
parent | d83d25dadec2c38460a32d96f5d2903426fec9d3 (diff) | |
parent | 702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff) | |
download | wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst wallabag-1953a872932a63792293b4aec087880265ba89f7.zip |
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'src/Wallabag/CoreBundle/Form')
4 files changed, 66 insertions, 14 deletions
diff --git a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php index cb4bee83..57dbc95e 100644 --- a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php +++ b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php | |||
@@ -48,7 +48,7 @@ class StringToListTransformer implements DataTransformerInterface | |||
48 | */ | 48 | */ |
49 | public function reverseTransform($string) | 49 | public function reverseTransform($string) |
50 | { | 50 | { |
51 | if ($string === null) { | 51 | if (null === $string) { |
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | 54 | ||
diff --git a/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php b/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php index c3715646..1627cc44 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php | |||
@@ -3,7 +3,6 @@ | |||
3 | namespace Wallabag\CoreBundle\Form\Type; | 3 | namespace Wallabag\CoreBundle\Form\Type; |
4 | 4 | ||
5 | use Symfony\Component\Form\AbstractType; | 5 | use Symfony\Component\Form\AbstractType; |
6 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | ||
7 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | 6 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
8 | use Symfony\Component\Form\Extension\Core\Type\TextType; | 7 | use Symfony\Component\Form\Extension\Core\Type\TextType; |
9 | use Symfony\Component\Form\FormBuilderInterface; | 8 | use Symfony\Component\Form\FormBuilderInterface; |
@@ -18,11 +17,6 @@ class EditEntryType extends AbstractType | |||
18 | 'required' => true, | 17 | 'required' => true, |
19 | 'label' => 'entry.edit.title_label', | 18 | 'label' => 'entry.edit.title_label', |
20 | ]) | 19 | ]) |
21 | ->add('is_public', CheckboxType::class, [ | ||
22 | 'required' => false, | ||
23 | 'label' => 'entry.edit.is_public_label', | ||
24 | 'property_path' => 'isPublic', | ||
25 | ]) | ||
26 | ->add('url', TextType::class, [ | 20 | ->add('url', TextType::class, [ |
27 | 'disabled' => true, | 21 | 'disabled' => true, |
28 | 'required' => false, | 22 | 'required' => false, |
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index 556578d1..6f8c9e27 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | |||
@@ -4,12 +4,12 @@ namespace Wallabag\CoreBundle\Form\Type; | |||
4 | 4 | ||
5 | use Doctrine\ORM\EntityRepository; | 5 | use Doctrine\ORM\EntityRepository; |
6 | use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands; | 6 | use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands; |
7 | use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; | ||
8 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType; | ||
9 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType; | ||
10 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType; | ||
11 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; | 7 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; |
12 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; | 8 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; |
9 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType; | ||
10 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType; | ||
11 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType; | ||
12 | use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; | ||
13 | use Symfony\Component\Form\AbstractType; | 13 | use Symfony\Component\Form\AbstractType; |
14 | use Symfony\Component\Form\FormBuilderInterface; | 14 | use Symfony\Component\Form\FormBuilderInterface; |
15 | use Symfony\Component\HttpFoundation\Response; | 15 | use Symfony\Component\HttpFoundation\Response; |
@@ -99,7 +99,7 @@ class EntryFilterType extends AbstractType | |||
99 | if (strlen($value) <= 2 || empty($value)) { | 99 | if (strlen($value) <= 2 || empty($value)) { |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%'.$value.'%'))); | 102 | $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%'))); |
103 | 103 | ||
104 | return $filterQuery->createCondition($expression); | 104 | return $filterQuery->createCondition($expression); |
105 | }, | 105 | }, |
@@ -113,8 +113,8 @@ class EntryFilterType extends AbstractType | |||
113 | } | 113 | } |
114 | 114 | ||
115 | $paramName = sprintf('%s', str_replace('.', '_', $field)); | 115 | $paramName = sprintf('%s', str_replace('.', '_', $field)); |
116 | $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName); | 116 | $expression = $filterQuery->getExpr()->eq($field, ':' . $paramName); |
117 | $parameters = array($paramName => $value); | 117 | $parameters = [$paramName => $value]; |
118 | 118 | ||
119 | return $filterQuery->createCondition($expression, $parameters); | 119 | return $filterQuery->createCondition($expression, $parameters); |
120 | }, | 120 | }, |
@@ -150,6 +150,20 @@ class EntryFilterType extends AbstractType | |||
150 | }, | 150 | }, |
151 | 'label' => 'entry.filters.preview_picture_label', | 151 | 'label' => 'entry.filters.preview_picture_label', |
152 | ]) | 152 | ]) |
153 | ->add('isPublic', CheckboxFilterType::class, [ | ||
154 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { | ||
155 | if (false === $values['value']) { | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | // is_public isn't a real field | ||
160 | // we should use the "uid" field to determine if the entry has been made public | ||
161 | $expression = $filterQuery->getExpr()->isNotNull($values['alias'] . '.uid'); | ||
162 | |||
163 | return $filterQuery->createCondition($expression); | ||
164 | }, | ||
165 | 'label' => 'entry.filters.is_public_label', | ||
166 | ]) | ||
153 | ->add('language', ChoiceFilterType::class, [ | 167 | ->add('language', ChoiceFilterType::class, [ |
154 | 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), | 168 | 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), |
155 | 'label' => 'entry.filters.language_label', | 169 | 'label' => 'entry.filters.language_label', |
diff --git a/src/Wallabag/CoreBundle/Form/Type/SiteCredentialType.php b/src/Wallabag/CoreBundle/Form/Type/SiteCredentialType.php new file mode 100644 index 00000000..fd409ad2 --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/SiteCredentialType.php | |||
@@ -0,0 +1,44 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Form\Type; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||
7 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
8 | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
9 | use Symfony\Component\Form\FormBuilderInterface; | ||
10 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
11 | |||
12 | class SiteCredentialType extends AbstractType | ||
13 | { | ||
14 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
15 | { | ||
16 | $builder | ||
17 | ->add('host', TextType::class, [ | ||
18 | 'label' => 'site_credential.form.host_label', | ||
19 | ]) | ||
20 | ->add('username', TextType::class, [ | ||
21 | 'label' => 'site_credential.form.username_label', | ||
22 | 'data' => '', | ||
23 | ]) | ||
24 | ->add('password', PasswordType::class, [ | ||
25 | 'label' => 'site_credential.form.password_label', | ||
26 | ]) | ||
27 | ->add('save', SubmitType::class, [ | ||
28 | 'label' => 'config.form.save', | ||
29 | ]) | ||
30 | ; | ||
31 | } | ||
32 | |||
33 | public function configureOptions(OptionsResolver $resolver) | ||
34 | { | ||
35 | $resolver->setDefaults([ | ||
36 | 'data_class' => 'Wallabag\CoreBundle\Entity\SiteCredential', | ||
37 | ]); | ||
38 | } | ||
39 | |||
40 | public function getBlockPrefix() | ||
41 | { | ||
42 | return 'site_credential'; | ||
43 | } | ||
44 | } | ||