Fixed negative order in searches
This commit is contained in:
parent
0945ed64ee
commit
eb77b6811a
1 changed files with 9 additions and 3 deletions
|
@ -17,7 +17,7 @@ abstract class AbstractSearchParser
|
||||||
public function createFilterFromInputReader(InputReader $inputReader)
|
public function createFilterFromInputReader(InputReader $inputReader)
|
||||||
{
|
{
|
||||||
$filter = $this->createFilter();
|
$filter = $this->createFilter();
|
||||||
$filter->setOrder($this->getOrder($inputReader->order) + $filter->getOrder());
|
$filter->setOrder($this->getOrder($inputReader->order, false) + $filter->getOrder());
|
||||||
|
|
||||||
if ($inputReader->page)
|
if ($inputReader->page)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ abstract class AbstractSearchParser
|
||||||
if ($token instanceof NamedSearchToken)
|
if ($token instanceof NamedSearchToken)
|
||||||
{
|
{
|
||||||
if ($token->getKey() === 'order')
|
if ($token->getKey() === 'order')
|
||||||
$filter->setOrder($this->getOrder($token->getValue()) + $filter->getOrder());
|
$filter->setOrder($this->getOrder($token->getValue(), $token->isNegated()) + $filter->getOrder());
|
||||||
else
|
else
|
||||||
$this->decorateFilterFromNamedToken($filter, $token);
|
$this->decorateFilterFromNamedToken($filter, $token);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ abstract class AbstractSearchParser
|
||||||
$filter->addRequirement($requirement);
|
$filter->addRequirement($requirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getOrder($query)
|
private function getOrder($query, $negated)
|
||||||
{
|
{
|
||||||
$order = [];
|
$order = [];
|
||||||
$tokens = array_filter(preg_split('/\s+/', trim($query)));
|
$tokens = array_filter(preg_split('/\s+/', trim($query)));
|
||||||
|
@ -125,6 +125,12 @@ abstract class AbstractSearchParser
|
||||||
if ($orderColumn === null)
|
if ($orderColumn === null)
|
||||||
throw new \InvalidArgumentException('Invalid search order token: ' . $orderToken);
|
throw new \InvalidArgumentException('Invalid search order token: ' . $orderToken);
|
||||||
|
|
||||||
|
if ($negated)
|
||||||
|
{
|
||||||
|
$orderDir = $orderDir == IFilter::ORDER_DESC ? IFilter::ORDER_ASC : IFilter::ORDER_DESC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$order[$orderColumn] = $orderDir;
|
$order[$orderColumn] = $orderDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue