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


PHP Filter::matchAny方法代码示例

本文整理汇总了PHP中Icinga\Data\Filter\Filter::matchAny方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::matchAny方法的具体用法?PHP Filter::matchAny怎么用?PHP Filter::matchAny使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Icinga\Data\Filter\Filter的用法示例。


在下文中一共展示了Filter::matchAny方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFilter

 /**
  * @return Filter
  */
 public function getFilter()
 {
     if ($this->filter === null) {
         $this->filter = Filter::matchAny();
     }
     return $this->filter;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:10,代码来源:ObjectList.php

示例2: applyRestriction

 /**
  * Apply a restriction on the given data view
  *
  * @param   string      $restriction    The name of restriction
  * @param   Filterable  $filterable     The filterable to restrict
  *
  * @return  Filterable  The filterable
  */
 protected static function applyRestriction($restriction, Filterable $filterable)
 {
     $restrictions = Filter::matchAny();
     foreach (Manager::getInstance()->getRestrictions($restriction) as $filter) {
         $restrictions->addFilter(Filter::fromQueryString($filter));
     }
     $filterable->applyFilter($restrictions);
     return $filterable;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:17,代码来源:MonitoringMenuItemRenderer.php

示例3: getFilter

 /**
  * Return the corresponding filter-object
  *
  * @returns Filter
  */
 public function getFilter()
 {
     $baseFilter = Filter::matchAny(Filter::expression('type', '=', 'hard_state'));
     if ($this->getValue('objecttype', 'hosts') === 'hosts') {
         $objectTypeFilter = Filter::expression('object_type', '=', 'host');
     } else {
         $objectTypeFilter = Filter::expression('object_type', '=', 'service');
     }
     $states = array('cnt_down_hard' => Filter::expression('state', '=', '1'), 'cnt_unreachable_hard' => Filter::expression('state', '=', '2'), 'cnt_up' => Filter::expression('state', '=', '0'), 'cnt_critical_hard' => Filter::expression('state', '=', '2'), 'cnt_warning_hard' => Filter::expression('state', '=', '1'), 'cnt_unknown_hard' => Filter::expression('state', '=', '3'), 'cnt_ok' => Filter::expression('state', '=', '0'));
     $state = $this->getValue('state', 'cnt_critical_hard');
     $stateFilter = $states[$state];
     if (in_array($state, array('cnt_ok', 'cnt_up'))) {
         return Filter::matchAll($objectTypeFilter, $stateFilter);
     }
     return Filter::matchAll($baseFilter, $objectTypeFilter, $stateFilter);
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:21,代码来源:StatehistoryForm.php

示例4: applyRestriction

 /**
  * Apply a restriction on the given data view
  *
  * @param   string      $restriction    The name of restriction
  * @param   Filterable  $view           The filterable to restrict
  *
  * @return  Filterable  The filterable
  */
 protected function applyRestriction($restriction, Filterable $view)
 {
     $restrictions = Filter::matchAny();
     $restrictions->setAllowedFilterColumns(array('host_name', 'hostgroup_name', 'service_description', 'servicegroup_name', function ($c) {
         return preg_match('/^_(?:host|service)_/', $c);
     }));
     foreach ($this->getRestrictions($restriction) as $filter) {
         try {
             $restrictions->addFilter(Filter::fromQueryString($filter));
         } catch (QueryException $e) {
             throw new ConfigurationError($this->translate('Cannot apply restriction %s using the filter %s. You can only use the following columns: %s'), $restriction, $filter, implode(', ', array('host_name', 'hostgroup_name', 'service_description', 'servicegroup_name', '_(host|service)_<customvar-name>')), $e);
         }
     }
     $view->applyFilter($restrictions);
     return $view;
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:24,代码来源:Controller.php

示例5: onSuccess

 /**
  * {@inheritdoc}
  */
 public function onSuccess()
 {
     $cookie = new AnnouncementCookie();
     $repo = new AnnouncementIniRepository();
     $query = $repo->findActive();
     $filter = array();
     foreach ($cookie->getAcknowledged() as $hash) {
         $filter[] = Filter::expression('hash', '=', $hash);
     }
     $query->addFilter(Filter::matchAny($filter));
     $acknowledged = array();
     foreach ($query as $row) {
         $acknowledged[] = $row->hash;
     }
     $acknowledged[] = $this->getElement('hash')->getValue();
     $cookie->setAcknowledged($acknowledged);
     $this->getResponse()->setCookie($cookie);
     return true;
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:22,代码来源:AcknowledgeAnnouncementForm.php

示例6: applyChanges

 protected function applyChanges($changes)
 {
     $filter = $this->filter;
     $pairs = array();
     $addTo = null;
     $add = array();
     foreach ($changes as $k => $v) {
         if (preg_match('/^(column|value|sign|operator)((?:_new)?)_([\\d-]+)$/', $k, $m)) {
             if ($m[2] === '_new') {
                 if ($addTo !== null && $addTo !== $m[3]) {
                     throw new \Exception('F...U');
                 }
                 $addTo = $m[3];
                 $add[$m[1]] = $v;
             } else {
                 $pairs[$m[3]][$m[1]] = $v;
             }
         }
     }
     $operators = array();
     foreach ($pairs as $id => $fs) {
         if (array_key_exists('operator', $fs)) {
             $operators[$id] = $fs['operator'];
         } else {
             $f = $filter->getById($id);
             $f->setColumn($fs['column']);
             if ($f->getSign() !== $fs['sign']) {
                 if ($f->isRootNode()) {
                     $filter = $f->setSign($fs['sign']);
                 } else {
                     $filter->replaceById($id, $f->setSign($fs['sign']));
                 }
             }
             $f->setExpression($fs['value']);
         }
     }
     krsort($operators, version_compare(PHP_VERSION, '5.4.0') >= 0 ? SORT_NATURAL : SORT_REGULAR);
     foreach ($operators as $id => $operator) {
         $f = $filter->getById($id);
         if ($f->getOperatorName() !== $operator) {
             if ($f->isRootNode()) {
                 $filter = $f->setOperatorName($operator);
             } else {
                 $filter->replaceById($id, $f->setOperatorName($operator));
             }
         }
     }
     if ($addTo !== null) {
         if ($addTo === '0') {
             $filter = Filter::expression($add['column'], $add['sign'], $add['value']);
         } else {
             $parent = $filter->getById($addTo);
             $f = Filter::expression($add['column'], $add['sign'], $add['value']);
             if (isset($add['operator'])) {
                 switch ($add['operator']) {
                     case 'AND':
                         if ($parent->isExpression()) {
                             if ($parent->isRootNode()) {
                                 $filter = Filter::matchAll(clone $parent, $f);
                             } else {
                                 $filter = $filter->replaceById($addTo, Filter::matchAll(clone $parent, $f));
                             }
                         } else {
                             $parent->addFilter(Filter::matchAll($f));
                         }
                         break;
                     case 'OR':
                         if ($parent->isExpression()) {
                             if ($parent->isRootNode()) {
                                 $filter = Filter::matchAny(clone $parent, $f);
                             } else {
                                 $filter = $filter->replaceById($addTo, Filter::matchAny(clone $parent, $f));
                             }
                         } else {
                             $parent->addFilter(Filter::matchAny($f));
                         }
                         break;
                     case 'NOT':
                         if ($parent->isExpression()) {
                             if ($parent->isRootNode()) {
                                 $filter = Filter::not(Filter::matchAll($parent, $f));
                             } else {
                                 $filter = $filter->replaceById($addTo, Filter::not(Filter::matchAll($parent, $f)));
                             }
                         } else {
                             $parent->addFilter(Filter::not($f));
                         }
                         break;
                 }
             } else {
                 $parent->addFilter($f);
             }
         }
     }
     return $filter;
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:96,代码来源:FilterEditor.php

示例7: flappingFilter

 public function flappingFilter()
 {
     return Filter::matchAny(Filter::expression('type', '=', 'flapping'), Filter::expression('type', '=', 'flapping_deleted'));
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:4,代码来源:EventOverviewForm.php

示例8: orFilter

 public function orFilter(Filter $filter)
 {
     return Filter::matchAny($this, $filter);
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:4,代码来源:FilterExpression.php

示例9: testManualFilterCreation

 public function testManualFilterCreation()
 {
     $filter = Filter::matchAll(Filter::where('host', '*localhost*'), Filter::matchAny(Filter::where('service', 'ping'), Filter::matchAll(Filter::where('service', 'www.icinga.org'), Filter::where('state', '0'))));
     $this->assertTrue($filter->matches($this->row(0)));
     $this->assertTrue($filter->matches($this->row(1)));
     $this->assertFalse($filter->matches($this->row(2)));
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:7,代码来源:FilterTest.php

示例10: findNextActive

 /**
  * Get the timestamp of the next active announcement
  *
  * @return  int|null
  */
 public function findNextActive()
 {
     $now = new DateTime();
     $query = $this->select(array('start', 'end'))->setFilter(Filter::matchAny(array(Filter::expression('start', '>', $now), Filter::expression('end', '>', $now))));
     $refresh = null;
     foreach ($query as $row) {
         $min = min($row->start->getTimestamp(), $row->end->getTimestamp());
         if ($refresh === null) {
             $refresh = $min;
         } else {
             $refresh = min($refresh, $min);
         }
     }
     return $refresh;
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:20,代码来源:AnnouncementIniRepository.php

示例11: reallyRetrieveStatesFromBackend

 public function reallyRetrieveStatesFromBackend()
 {
     Benchmark::measure('Retrieving states for business process ' . $this->getName());
     $backend = $this->getBackend();
     // TODO: Split apart, create a dedicated function.
     //       Separate "parse-logic" from "retrieve-state-logic"
     //       Allow DB-based backend
     //       Use IcingaWeb2 Multi-Backend-Support
     $check_results = array();
     $hostFilter = array_keys($this->hosts);
     if ($this->state_type === self::HARD_STATE) {
         $hostStateColumn = 'host_hard_state';
         $hostStateChangeColumn = 'host_last_hard_state_change';
         $serviceStateColumn = 'service_hard_state';
         $serviceStateChangeColumn = 'service_last_hard_state_change';
     } else {
         $hostStateColumn = 'host_state';
         $hostStateChangeColumn = 'host_last_state_change';
         $serviceStateColumn = 'service_state';
         $serviceStateChangeColumn = 'service_last_state_change';
     }
     $filter = Filter::matchAny();
     foreach ($hostFilter as $host) {
         $filter->addFilter(Filter::where('host_name', $host));
     }
     if ($filter->isEmpty()) {
         return $this;
     }
     $hostStatus = $backend->select()->from('hostStatus', array('hostname' => 'host_name', 'last_state_change' => $hostStateChangeColumn, 'in_downtime' => 'host_in_downtime', 'ack' => 'host_acknowledged', 'state' => $hostStateColumn))->applyFilter($filter)->getQuery()->fetchAll();
     $serviceStatus = $backend->select()->from('serviceStatus', array('hostname' => 'host_name', 'service' => 'service_description', 'last_state_change' => $serviceStateChangeColumn, 'in_downtime' => 'service_in_downtime', 'ack' => 'service_acknowledged', 'state' => $serviceStateColumn))->applyFilter($filter)->getQuery()->fetchAll();
     foreach ($serviceStatus as $row) {
         $this->handleDbRow($row);
     }
     foreach ($hostStatus as $row) {
         $this->handleDbRow($row);
     }
     ksort($this->root_nodes);
     Benchmark::measure('Got states for business process ' . $this->getName());
     return $this;
 }
开发者ID:0svald,项目名称:icingaweb2-module-businessprocess,代码行数:40,代码来源:BusinessProcess.php

示例12: filterEventTypes

 /**
  * Applies the name filter of EventType restrictions onto a Query
  *
  * @param RepositoryQuery $query
  */
 public function filterEventTypes(RepositoryQuery $query)
 {
     $allowedTypes = $this->canEventTypes();
     if (!empty($allowedTypes)) {
         $filter = Filter::matchAny();
         foreach ($allowedTypes as $type) {
             $here = Filter::where('name', $type);
             $filter->addFilter($here);
         }
         $query->addFilter($filter);
     }
 }
开发者ID:Icinga,项目名称:icingaweb2-module-elasticsearch,代码行数:17,代码来源:Controller.php


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