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


PHP Filter::expression方法代码示例

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


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

示例1: setSign

 public function setSign($sign)
 {
     if ($sign !== $this->sign) {
         return Filter::expression($this->column, $sign, $this->expression);
     }
     return $this;
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:7,代码来源:FilterExpression.php

示例2: render

 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $repo = new AnnouncementIniRepository();
     $etag = $repo->getEtag();
     $cookie = new AnnouncementCookie();
     if ($cookie->getEtag() !== $etag) {
         $cookie->setEtag($etag);
         $cookie->setNextActive($repo->findNextActive());
         Icinga::app()->getResponse()->setCookie($cookie);
     }
     $acked = array();
     foreach ($cookie->getAcknowledged() as $hash) {
         $acked[] = Filter::expression('hash', '!=', $hash);
     }
     $acked = Filter::matchAll($acked);
     $announcements = $repo->findActive();
     $announcements->applyFilter($acked);
     if ($announcements->hasResult()) {
         $html = '<ul role="alert" id="announcements">';
         foreach ($announcements as $announcement) {
             $ackForm = new AcknowledgeAnnouncementForm();
             $ackForm->populate(array('hash' => $announcement->hash));
             $html .= '<li><div>' . $this->view()->escape($announcement->message) . '</div>' . $ackForm . '</li>';
         }
         $html .= '</ul>';
         return $html;
     }
     // Force container update on XHR
     return '<div style="display: none;"></div>';
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:33,代码来源:Announcements.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: 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

示例5: 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

示例6: flappingFilter

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

示例7: where

 /**
  * Add a where condition to the query by and
  *
  * The syntax of the condition and valid values are defined by the concrete backend-specific query implementation.
  *
  * @param   string  $condition
  * @param   mixed   $value
  *
  * @return  $this
  */
 public function where($condition, $value = null)
 {
     // TODO: more intelligence please
     $this->filter->addFilter(Filter::expression($condition, '=', $value));
     return $this;
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:16,代码来源:SimpleQuery.php

示例8: fetchResults

 /**
  * Fetch all entries and forecasts by using the dataview associated with this timeline
  *
  * @return  array       The dataview's result
  */
 private function fetchResults()
 {
     $hookResults = array();
     foreach (Hook::all('timeline') as $timelineProvider) {
         $hookResults = array_merge($hookResults, $timelineProvider->fetchEntries($this->displayRange), $timelineProvider->fetchForecasts($this->forecastRange));
         foreach ($timelineProvider->getIdentifiers() as $identifier => $attributes) {
             if (!array_key_exists($identifier, $this->identifiers)) {
                 $this->identifiers[$identifier] = $attributes;
             }
         }
     }
     $query = $this->dataview;
     $filter = Filter::matchAll(Filter::where('type', array_keys($this->identifiers)), Filter::expression('timestamp', '<=', $this->displayRange->getStart()->getTimestamp()), Filter::expression('timestamp', '>', $this->displayRange->getEnd()->getTimestamp()));
     $query->applyFilter($filter);
     return array_merge($query->getQuery()->fetchAll(), $hookResults);
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:21,代码来源:TimeLine.php

示例9: 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


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