backend->list('host')->handleRequest()->fetchAll() $hostList = new HostList($this->backend); $this->applyRestriction('monitoring/filter/objects', $hostList); $hostList->addFilter(Filter::fromQueryString((string) $this->params)); if (! $hostList->count()) { // @TODO(el): Use ApiResponse class for unified response handling. $this->getRequest()->sendJson(array( 'status' => 'fail', 'message' => 'No hosts found matching the given filter' )); } $form = new ScheduleHostDowntimeCommandForm(); $form ->setIsApiTarget(true) ->setObjects($hostList->fetch()) ->handleRequest($this->getRequest()); } /** * Remove host downtimes */ public function removeHostDowntimeAction() { // @TODO(el): Require a filter $downtimes = $this->backend ->select() ->from('downtime', array('host_name', 'id' => 'downtime_internal_id')) ->where('object_type', 'host') ->applyFilter($this->getRestriction('monitoring/filter/objects')) ->handleRequest($this->getRequest()) ->fetchAll(); if (empty($downtimes)) { // @TODO(el): Use ApiResponse class for unified response handling. $this->getRequest()->sendJson(array( 'status' => 'fail', 'message' => 'No downtimes found matching the given filter' )); } $form = new DeleteDowntimesCommandForm(); $form ->setIsApiTarget(true) ->setDowntimes($downtimes) ->handleRequest($this->getRequest()); // @TODO(el): Respond w/ the downtimes deleted instead of the notifiaction added by // DeleteDowntimesCommandForm::onSuccess(). } }