]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Filter/EntryFilterType.php
forgot case for previewPicture filter
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Filter / EntryFilterType.php
index d1057fb56f7d9a4a6231fd11e2cdf70a9d6c71e9..11c69abdf9ea4f21ef6083fda665636ecf46b796 100644 (file)
@@ -5,7 +5,6 @@ namespace Wallabag\CoreBundle\Filter;
 use Symfony\Component\Form\AbstractType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\OptionsResolver\OptionsResolver;
-use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
 use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
 
 class EntryFilterType extends AbstractType
@@ -17,26 +16,45 @@ class EntryFilterType extends AbstractType
             ->add('createdAt', 'filter_date_range', array(
                     'left_date_options' => array(
                         'attr' => array(
-                            'placeholder' => 'dd/mm/yyyy'),
+                            'placeholder' => 'dd/mm/yyyy',
+                        ),
                         'format' => 'dd/MM/yyyy',
-                        'widget' => 'single_text'
+                        'widget' => 'single_text',
                     ),
                     'right_date_options' => array(
                         'attr' => array(
-                            'placeholder' => 'dd/mm/yyyy'),
+                            'placeholder' => 'dd/mm/yyyy',
+                        ),
                         'format' => 'dd/MM/yyyy',
-                        'widget' => 'single_text'
-                )))
+                        'widget' => 'single_text',
+                    ),
+                )
+            )
             ->add('domainName', 'filter_text', array(
-                'apply_filter' => function (QueryInterface $filterQuery, $field, $values)
-                    {
+                'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
                         $value = $values['value'];
                         if (strlen($value) <= 3 || empty($value)) {
-                            return null;
+                            return;
                         }
                         $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%'));
+
                         return $filterQuery->createCondition($expression);
+                },
+            ))
+            ->add('isArchived', 'filter_checkbox')
+            ->add('isStarred', 'filter_checkbox')
+            ->add('previewPicture', 'filter_checkbox', array(
+                'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
+                    $value = $values['value'];
+
+                    if (false === $value) {
+                        return;
                     }
+
+                    $expression = $filterQuery->getExpr()->isNotNull($field);
+
+                    return $filterQuery->createCondition($expression);
+                },
             ));
     }
 
@@ -48,8 +66,8 @@ class EntryFilterType extends AbstractType
     public function configureOptions(OptionsResolver $resolver)
     {
         $resolver->setDefaults(array(
-            'csrf_protection'   => false,
-            'validation_groups' => array('filtering')
+            'csrf_protection' => false,
+            'validation_groups' => array('filtering'),
         ));
     }
 }