public function toDQL() { $dql = "("; $els = array(); if (empty($this->children)) { return false; } foreach ($this->children as $child) { if (IcingaDQLViewFilter::isGroup($child)) { $keys = array_keys($child); $subEl = new IcingaDQLViewFilterGroup($child[$keys[0]], $keys[0], $this->negate, $this->template); $els[] = $subEl->toDQL(); $this->values = array_merge($this->values, $subEl->getValues()); } else { $subEl = new IcingaDQLViewFilterElement($child, $this->negate, $this->template); $els[] = $subEl->toDQL(); $this->values[] = $subEl->getValue(); } } $cleared = array(); foreach ($els as $element) { if ($element == "") { continue; } $cleared[] = $element; } if (empty($cleared)) { return false; } return "(" . join(" " . $this->type . " ", $cleared) . ")"; }