本文整理汇总了PHP中Icinga\Data\Filter\Filter::isChain方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::isChain方法的具体用法?PHP Filter::isChain怎么用?PHP Filter::isChain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Data\Filter\Filter
的用法示例。
在下文中一共展示了Filter::isChain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterToArray
protected function filterToArray(Filter $filter)
{
if ($filter->isChain()) {
return $this->filterChainToArray($filter);
} else {
return $this->filterExpressionToArray($filter);
}
return $array;
}
示例2: renderFilter
/**
* Renders the Elasticsearch query as a recursive function, walking through the FilterChain.
*
* @param Filter $filter Current object
* @param int $level Current depth in integer
*
* @return array|null|string
*
* @throws ProgrammingError
*/
protected function renderFilter(Filter $filter, $level = 0)
{
$container = array();
if ($filter->isChain()) {
if ($filter instanceof FilterAnd) {
$section = 'must';
} elseif ($filter instanceof FilterOr) {
$section = 'should';
} elseif ($filter instanceof FilterNot) {
$section = 'must_not';
} else {
throw new ProgrammingError('Cannot render filter chain type: %s', get_class($filter));
}
if (!$filter->isEmpty()) {
/** @var Filter $filterPart */
foreach ($filter->filters() as $filterPart) {
$part = $this->renderFilter($filterPart, $level + 1);
if ($part) {
if ($filter instanceof FilterNot) {
// add in a new bool to flip expression
if ($filterPart instanceof FilterMatchNot) {
$container[$section][] = array('bool' => array('must_not' => $part));
continue;
}
} elseif ($filter instanceof FilterAnd) {
// add match not to must_not instead of must
if ($filterPart instanceof FilterMatchNot) {
$container['must_not'][] = $part;
continue;
} elseif ($filterPart instanceof FilterNot) {
$container['must_not'] = $part['bool']['must_not'];
continue;
}
}
$container[$section][] = $part;
}
}
// return the bool of the chain
return array('bool' => $container);
} else {
// return match_all
return array('match_all' => (object) array());
}
} else {
// return the simple part
return $this->renderFilterExpression($filter);
}
}
示例3: resetSearchColumns
protected function resetSearchColumns(Filter &$filter)
{
if ($filter->isChain()) {
$filters =& $filter->filters();
if (!($empty = empty($filters))) {
foreach ($filters as $k => &$f) {
if (false === $this->resetSearchColumns($f)) {
unset($filters[$k]);
}
}
}
return $empty || !empty($filters);
}
return $filter->isExpression() ? !(in_array($filter->getColumn(), $this->searchColumns) && $filter->getSign() === '=') : true;
}
示例4: renderFilter
/**
* Render and return the given filter as SQL-WHERE clause
*
* @param Filter $filter
*
* @return string
*/
public function renderFilter(Filter $filter, $level = 0)
{
// TODO: This is supposed to supersede DbQuery::renderFilter()
$where = '';
if ($filter->isChain()) {
if ($filter instanceof FilterAnd) {
$operator = ' AND ';
} elseif ($filter instanceof FilterOr) {
$operator = ' OR ';
} elseif ($filter instanceof FilterNot) {
$operator = ' AND ';
$where .= ' NOT ';
} else {
throw new ProgrammingError('Cannot render filter: %s', get_class($filter));
}
if (!$filter->isEmpty()) {
$parts = array();
foreach ($filter->filters() as $filterPart) {
$part = $this->renderFilter($filterPart, $level + 1);
if ($part) {
$parts[] = $part;
}
}
if (!empty($parts)) {
if ($level > 0) {
$where .= ' (' . implode($operator, $parts) . ') ';
} else {
$where .= implode($operator, $parts);
}
}
} else {
return '';
// Explicitly return the empty string due to the FilterNot case
}
} else {
$where .= $this->renderFilterExpression($filter);
}
return $where;
}
示例5: addFilter
public function addFilter(Filter $filter)
{
// TODO: This should be considered a quick fix only.
// Drop this entirely once support for Icinga\Data\Filter is available
if ($filter->isExpression()) {
$this->where($filter->getColumn(), $filter->getExpression());
} elseif ($filter->isChain()) {
foreach ($filter->filters() as $chainOrExpression) {
$this->addFilter($chainOrExpression);
}
}
}