X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FForm%2FType%2FEntryFilterType.php;h=61ad99a8656c0b28f9a8fea472c05226d63fb36c;hb=8ee7b1603d23297a6c183105f79b1290ce9828bf;hp=6a4c485f6d696f4525c354c1865ea3d7c0a6b3e4;hpb=42708d1121fef12c84487247b170eb03083d5ffc;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index 6a4c485f..61ad99a8 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -4,12 +4,12 @@ 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; -use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; +use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType; +use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType; +use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType; +use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\HttpFoundation\Response; @@ -23,9 +23,6 @@ class EntryFilterType extends AbstractType /** * Repository & user are used to get a list of language entries for this user. - * - * @param EntityRepository $entryRepository - * @param TokenStorageInterface $tokenStorage */ public function __construct(EntityRepository $entryRepository, TokenStorageInterface $tokenStorage) { @@ -33,7 +30,7 @@ class EntryFilterType extends AbstractType $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null; - if (null === $this->user || !is_object($this->user)) { + if (null === $this->user || !\is_object($this->user)) { return; } } @@ -54,8 +51,8 @@ class EntryFilterType extends AbstractType $lower = $values['value']['left_number'][0]; $upper = $values['value']['right_number'][0]; - $min = (int) ($lower * $this->user->getConfig()->getReadingSpeed()); - $max = (int) ($upper * $this->user->getConfig()->getReadingSpeed()); + $min = (int) ($lower * $this->user->getConfig()->getReadingSpeed() / 200); + $max = (int) ($upper * $this->user->getConfig()->getReadingSpeed() / 200); if (null === $lower && null === $upper) { // no value? no filter @@ -76,30 +73,29 @@ class EntryFilterType extends AbstractType 'label' => 'entry.filters.reading_time.label', ]) ->add('createdAt', DateRangeFilterType::class, [ - 'left_date_options' => [ - 'attr' => [ - 'placeholder' => 'dd/mm/yyyy', - ], - 'format' => 'dd/MM/yyyy', - 'widget' => 'single_text', + 'left_date_options' => [ + 'attr' => [ + 'placeholder' => 'yyyy-mm-dd', ], - 'right_date_options' => [ - 'attr' => [ - 'placeholder' => 'dd/mm/yyyy', - ], - 'format' => 'dd/MM/yyyy', - 'widget' => 'single_text', + 'format' => 'yyyy-MM-dd', + 'widget' => 'single_text', + ], + 'right_date_options' => [ + 'attr' => [ + 'placeholder' => 'yyyy-mm-dd', ], - 'label' => 'entry.filters.created_at.label', - ] - ) + 'format' => 'yyyy-MM-dd', + 'widget' => 'single_text', + ], + 'label' => 'entry.filters.created_at.label', + ]) ->add('domainName', TextFilterType::class, [ 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { $value = $values['value']; - if (strlen($value) <= 2 || empty($value)) { + if (\strlen($value) <= 2 || empty($value)) { return; } - $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%'.$value.'%'))); + $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%'))); return $filterQuery->createCondition($expression); }, @@ -108,13 +104,13 @@ class EntryFilterType extends AbstractType ->add('httpStatus', TextFilterType::class, [ 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { $value = $values['value']; - if (false === array_key_exists($value, Response::$statusTexts)) { + 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); + $expression = $filterQuery->getExpr()->eq($field, ':' . $paramName); + $parameters = [$paramName => $value]; return $filterQuery->createCondition($expression, $parameters); }, @@ -158,7 +154,7 @@ class EntryFilterType extends AbstractType // 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'); + $expression = $filterQuery->getExpr()->isNotNull($values['alias'] . '.uid'); return $filterQuery->createCondition($expression); },