protected function _buildFilter($type, $conditions, $overwrite)
{
if ($this->_parts[$type] === null || $overwrite) {
$this->_parts[$type] = new BoolFilter();
}
if ($conditions instanceof AbstractFilter) {
$this->_parts[$type]->addMust($conditions);
return $this;
}
if (is_callable($conditions)) {
$conditions = $conditions(new FilterBuilder(), $this->_parts[$type], $this);
}
if ($conditions === null) {
return $this;
}
if (is_array($conditions)) {
$conditions = (new FilterBuilder())->parse($conditions);
array_map([$this->_parts[$type], 'addMust'], $conditions);
return $this;
}
$this->_parts[$type]->addMust($conditions);
return $this;
}