mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
Data\Filter: clean up a few things
* throw useful exceptions * our "id" should always be treated as a string
This commit is contained in:
parent
b7cdff6fa5
commit
97f88bf636
@ -3,7 +3,7 @@
|
|||||||
namespace Icinga\Data\Filter;
|
namespace Icinga\Data\Filter;
|
||||||
|
|
||||||
use Icinga\Web\UrlParams;
|
use Icinga\Web\UrlParams;
|
||||||
use Exception;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter
|
* Filter
|
||||||
@ -16,7 +16,7 @@ abstract class Filter
|
|||||||
|
|
||||||
public function setId($id)
|
public function setId($id)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = (string) $id;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,11 +29,11 @@ abstract class Filter
|
|||||||
|
|
||||||
public function getById($id)
|
public function getById($id)
|
||||||
{
|
{
|
||||||
if ($id === $this->getId()) {
|
if ((string) $id === $this->getId()) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
throw new Exception(sprintf(
|
throw new ProgrammingError(sprintf(
|
||||||
'Trying to get invalid filter index "%s" from "%s"', $id, $this
|
'Trying to get invalid filter index "%s" from "%s" ("%s")', $id, $this, $this->id
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,9 @@ abstract class Filter
|
|||||||
case '>=': return new FilterEqualOrGreaterThan($col, $op, $expression);
|
case '>=': return new FilterEqualOrGreaterThan($col, $op, $expression);
|
||||||
case '<=': return new FilterEqualOrLessThan($col, $op, $expression);
|
case '<=': return new FilterEqualOrLessThan($col, $op, $expression);
|
||||||
case '!=': return new FilterNotEqual($col, $op, $expression);
|
case '!=': return new FilterNotEqual($col, $op, $expression);
|
||||||
default: throw new \Exception('WTTTTF');
|
default: throw new ProgrammingError(
|
||||||
|
sprintf('There is no such filter sign: %s', $op)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,15 +138,4 @@ abstract class Filter
|
|||||||
{
|
{
|
||||||
return FilterQueryString::parse($query);
|
return FilterQueryString::parse($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We need a new Querystring-Parser
|
|
||||||
*
|
|
||||||
* Still TBD, should be able to read such syntax:
|
|
||||||
* (host_name=test&(service=ping|(service=http&host=*net*)))
|
|
||||||
*/
|
|
||||||
protected static function consumeStringUnless(& $string, $stop)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user