MonitoredObject: Deprecate method matches()

It's now possible to achieve the same by passing the object directly to a
filter.

refs #10304
This commit is contained in:
Johannes Meyer 2015-10-05 14:04:40 +02:00
parent 65e7f7a8ca
commit 6a68d25bc3
2 changed files with 4 additions and 33 deletions

View File

@ -231,6 +231,8 @@ abstract class MonitoredObject implements Filterable
* @return bool * @return bool
* *
* @throws ProgrammingError In case the object cannot be found * @throws ProgrammingError In case the object cannot be found
*
* @deprecated Use $filter->matches($object) instead
*/ */
public function matches(Filter $filter) public function matches(Filter $filter)
{ {
@ -242,38 +244,7 @@ abstract class MonitoredObject implements Filterable
); );
} }
$queryString = $filter->toQueryString(); return $filter->matches($this);
$row = clone $this->properties;
if (strpos($queryString, '_host_') !== false || strpos($queryString, '_service_') !== false) {
if ($this->customvars === null) {
$this->fetchCustomvars();
}
foreach ($this->customvars as $name => $value) {
if (! is_object($value)) {
$row->{'_' . $this->getType() . '_' . $name} = $value;
}
}
}
if (strpos($queryString, 'hostgroup_name') !== false) {
if ($this->hostgroups === null) {
$this->fetchHostgroups();
}
$row->hostgroup_name = array_keys($this->hostgroups);
}
if (strpos($queryString, 'servicegroup_name') !== false) {
if ($this->servicegroups === null) {
$this->fetchServicegroups();
}
$row->servicegroup_name = array_keys($this->servicegroups);
}
return $filter->matches($row);
} }
/** /**

View File

@ -101,7 +101,7 @@ class Action extends NavigationItem
{ {
if ($this->render === null) { if ($this->render === null) {
$filter = $this->getFilter(); $filter = $this->getFilter();
$this->render = $filter ? $this->getObject()->matches(Filter::fromQueryString($filter)) : true; $this->render = $filter ? Filter::fromQueryString($filter)->matches($this->getObject()) : true;
} }
return $this->render; return $this->render;