diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-05-03 09:05:31 +0200 |
---|---|---|
committer | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-05-03 09:05:31 +0200 |
commit | 2142c714ef997f4853b5649ab86d150e40e6f18a (patch) | |
tree | 59601deae1a0bf59ec7886be53f31dc422786a2c /src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | |
parent | 045859a2b502a9e94943e262ee80698af08619e1 (diff) | |
parent | c4c062cce00d8358b9a9c836aadcd8997f2fb069 (diff) | |
download | wallabag-2142c714ef997f4853b5649ab86d150e40e6f18a.tar.gz wallabag-2142c714ef997f4853b5649ab86d150e40e6f18a.tar.zst wallabag-2142c714ef997f4853b5649ab86d150e40e6f18a.zip |
Merge pull request #1976 from wallabag/fix-filter-readingTime
Fix filter reading time
Diffstat (limited to 'src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index dcdb3ab7..cd4d3490 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | |||
@@ -35,6 +35,20 @@ class EntryFilterType extends AbstractType | |||
35 | { | 35 | { |
36 | $builder | 36 | $builder |
37 | ->add('readingTime', NumberRangeFilterType::class, [ | 37 | ->add('readingTime', NumberRangeFilterType::class, [ |
38 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { | ||
39 | $value = $values['value']; | ||
40 | |||
41 | if (null === $value['left_number'][0] || null === $value['right_number'][0]) { | ||
42 | return; | ||
43 | } | ||
44 | |||
45 | $min = (int) ($value['left_number'][0] * $this->user->getConfig()->getReadingSpeed()); | ||
46 | $max = (int) ($value['right_number'][0] * $this->user->getConfig()->getReadingSpeed()); | ||
47 | |||
48 | $expression = $filterQuery->getExpr()->between($field, $min, $max); | ||
49 | |||
50 | return $filterQuery->createCondition($expression); | ||
51 | }, | ||
38 | 'label' => 'entry.filters.reading_time.label', | 52 | 'label' => 'entry.filters.reading_time.label', |
39 | ]) | 53 | ]) |
40 | ->add('createdAt', DateRangeFilterType::class, [ | 54 | ->add('createdAt', DateRangeFilterType::class, [ |