diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Filter/EntryFilterType.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Filter/EntryFilterType.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php index e0a1cb31..4430c971 100644 --- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php | |||
@@ -4,6 +4,11 @@ namespace Wallabag\CoreBundle\Filter; | |||
4 | 4 | ||
5 | use Doctrine\ORM\EntityRepository; | 5 | use Doctrine\ORM\EntityRepository; |
6 | use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; | 6 | use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; |
7 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType; | ||
8 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType; | ||
9 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType; | ||
10 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; | ||
11 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; | ||
7 | use Symfony\Component\Form\AbstractType; | 12 | use Symfony\Component\Form\AbstractType; |
8 | use Symfony\Component\Form\FormBuilderInterface; | 13 | use Symfony\Component\Form\FormBuilderInterface; |
9 | use Symfony\Component\OptionsResolver\OptionsResolver; | 14 | use Symfony\Component\OptionsResolver\OptionsResolver; |
@@ -29,8 +34,8 @@ class EntryFilterType extends AbstractType | |||
29 | public function buildForm(FormBuilderInterface $builder, array $options) | 34 | public function buildForm(FormBuilderInterface $builder, array $options) |
30 | { | 35 | { |
31 | $builder | 36 | $builder |
32 | ->add('readingTime', 'filter_number_range') | 37 | ->add('readingTime', NumberRangeFilterType::class) |
33 | ->add('createdAt', 'filter_date_range', array( | 38 | ->add('createdAt', DateRangeFilterType::class, array( |
34 | 'left_date_options' => array( | 39 | 'left_date_options' => array( |
35 | 'attr' => array( | 40 | 'attr' => array( |
36 | 'placeholder' => 'dd/mm/yyyy', | 41 | 'placeholder' => 'dd/mm/yyyy', |
@@ -47,7 +52,7 @@ class EntryFilterType extends AbstractType | |||
47 | ), | 52 | ), |
48 | ) | 53 | ) |
49 | ) | 54 | ) |
50 | ->add('domainName', 'filter_text', array( | 55 | ->add('domainName', TextFilterType::class, array( |
51 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { | 56 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { |
52 | $value = $values['value']; | 57 | $value = $values['value']; |
53 | if (strlen($value) <= 2 || empty($value)) { | 58 | if (strlen($value) <= 2 || empty($value)) { |
@@ -58,9 +63,9 @@ class EntryFilterType extends AbstractType | |||
58 | return $filterQuery->createCondition($expression); | 63 | return $filterQuery->createCondition($expression); |
59 | }, | 64 | }, |
60 | )) | 65 | )) |
61 | ->add('isArchived', 'filter_checkbox') | 66 | ->add('isArchived', CheckboxFilterType::class) |
62 | ->add('isStarred', 'filter_checkbox') | 67 | ->add('isStarred', CheckboxFilterType::class) |
63 | ->add('previewPicture', 'filter_checkbox', array( | 68 | ->add('previewPicture', CheckboxFilterType::class, array( |
64 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { | 69 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { |
65 | if (false === $values['value']) { | 70 | if (false === $values['value']) { |
66 | return; | 71 | return; |
@@ -71,8 +76,9 @@ class EntryFilterType extends AbstractType | |||
71 | return $filterQuery->createCondition($expression); | 76 | return $filterQuery->createCondition($expression); |
72 | }, | 77 | }, |
73 | )) | 78 | )) |
74 | ->add('language', 'filter_choice', array( | 79 | ->add('language', ChoiceFilterType::class, array( |
75 | 'choices' => $this->repository->findDistinctLanguageByUser($this->user->getId()), | 80 | 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), |
81 | 'choices_as_values' => true, | ||
76 | )) | 82 | )) |
77 | ; | 83 | ; |
78 | } | 84 | } |