X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FForm%2FType%2FEntryFilterType.php;fp=src%2FWallabag%2FCoreBundle%2FForm%2FType%2FEntryFilterType.php;h=7b02f85c35e336671d3ee19f87f22ef8be677aec;hp=a3e36fddd344304ed9c5630a38a905fba27f8bf8;hb=68003139e133835805b143b62c4407f19b495dab;hpb=cb1a6590c0e58c56d0612066501b3a586b103ed5 diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index a3e36fdd..7b02f85c 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -11,6 +11,7 @@ use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -95,6 +96,21 @@ class EntryFilterType extends AbstractType }, 'label' => 'entry.filters.domain_label', ]) + ->add('httpStatus', TextFilterType::class, [ + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + $value = $values['value']; + if (false === array_key_exists($value, Response::$statusTexts)) { + return; + } + + $paramName = sprintf('%s', str_replace('.', '_', $field)); + $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName); + $parameters = array($paramName => $value); + + return $filterQuery->createCondition($expression, $parameters); + }, + 'label' => 'entry.filters.http_status_label', + ]) ->add('isArchived', CheckboxFilterType::class, [ 'label' => 'entry.filters.archived_label', ])