X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FForm%2FType%2FEntryFilterType.php;h=6a4c485f6d696f4525c354c1865ea3d7c0a6b3e4;hb=e8911f7c09fa9d8009d7c7ee9fb0c181d2ffbc31;hp=ee66c728a88558cd21511076782418ef62674ab3;hpb=af54b2c9594394046a4596f89071fd9d30800f24;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index ee66c728..6a4c485f 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -3,6 +3,7 @@ namespace Wallabag\CoreBundle\Form\Type; use Doctrine\ORM\EntityRepository; +use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands; use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType; @@ -33,7 +34,7 @@ class EntryFilterType extends AbstractType $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null; if (null === $this->user || !is_object($this->user)) { - return null; + return; } } @@ -41,6 +42,14 @@ class EntryFilterType extends AbstractType { $builder ->add('readingTime', NumberRangeFilterType::class, [ + 'left_number_options' => [ + 'condition_operator' => FilterOperands::OPERATOR_GREATER_THAN_EQUAL, + 'attr' => ['min' => 0], + ], + 'right_number_options' => [ + 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL, + 'attr' => ['min' => 0], + ], 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { $lower = $values['value']['left_number'][0]; $upper = $values['value']['right_number'][0]; @@ -141,6 +150,20 @@ class EntryFilterType extends AbstractType }, 'label' => 'entry.filters.preview_picture_label', ]) + ->add('isPublic', CheckboxFilterType::class, [ + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + if (false === $values['value']) { + return; + } + + // is_public isn't a real field + // we should use the "uid" field to determine if the entry has been made public + $expression = $filterQuery->getExpr()->isNotNull($values['alias'].'.uid'); + + return $filterQuery->createCondition($expression); + }, + 'label' => 'entry.filters.is_public_label', + ]) ->add('language', ChoiceFilterType::class, [ 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), 'label' => 'entry.filters.language_label',