当前位置: 首页>>代码示例>>PHP>>正文


PHP Filter::isChain方法代码示例

本文整理汇总了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;
 }
开发者ID:Thomas-Gelf,项目名称:icingaweb2-module-puppetdb,代码行数:9,代码来源:FilterRenderer.php

示例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);
     }
 }
开发者ID:Icinga,项目名称:icingaweb2-module-elasticsearch,代码行数:58,代码来源:FilterRenderer.php

示例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;
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:15,代码来源:FilterEditor.php

示例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;
 }
开发者ID:scibi,项目名称:icingaweb2,代码行数:46,代码来源:DbConnection.php

示例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);
         }
     }
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:12,代码来源:LdapQuery.php


注:本文中的Icinga\Data\Filter\Filter::isChain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。