Data\Filter: add or/andFilter implementations
Those shortcuts make it easy to correctly add or/and conditions regardless of the original filter type
This commit is contained in:
parent
6aefc4b491
commit
925348d171
|
@ -30,6 +30,10 @@ abstract class Filter
|
|||
|
||||
abstract public function toQueryString();
|
||||
|
||||
abstract public function andFilter(Filter $filter);
|
||||
|
||||
abstract public function orFilter(Filter $filter);
|
||||
|
||||
public function getUrlParams()
|
||||
{
|
||||
return UrlParams::fromQueryString($this->toQueryString());
|
||||
|
|
|
@ -30,4 +30,14 @@ class FilterAnd extends FilterChain
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function andFilter(Filter $filter)
|
||||
{
|
||||
return $this->addFilter($filter);
|
||||
}
|
||||
|
||||
public function orFilter(Filter $filter)
|
||||
{
|
||||
return Filter::matchAny($this, $filter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,4 +107,14 @@ class FilterExpression extends Filter
|
|||
return (bool) preg_match($pattern, $row->{$this->column});
|
||||
}
|
||||
}
|
||||
|
||||
public function andFilter(Filter $filter)
|
||||
{
|
||||
return Filter::matchAll($this, $filter);
|
||||
}
|
||||
|
||||
public function orFilter(Filter $filter)
|
||||
{
|
||||
return Filter::matchAny($this, $filter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,16 @@ class FilterNot extends FilterChain
|
|||
return true;
|
||||
}
|
||||
|
||||
public function andFilter(Filter $filter)
|
||||
{
|
||||
return Filter::matchAll($this, $filter);
|
||||
}
|
||||
|
||||
public function orFilter(Filter $filter)
|
||||
{
|
||||
return Filter::matchAny($filter);
|
||||
}
|
||||
|
||||
public function toQueryString()
|
||||
{
|
||||
$parts = array();
|
||||
|
|
|
@ -19,4 +19,14 @@ class FilterOr extends FilterChain
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function andFilter(Filter $filter)
|
||||
{
|
||||
return Filter::matchAll($this, $filter);
|
||||
}
|
||||
|
||||
public function orFilter(Filter $filter)
|
||||
{
|
||||
return $this->addFilter($filter);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue