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


PHP Filter::not方法代码示例

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


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

示例1: createElements

 /**
  * Create and add elements to this form
  *
  * @param   array   $formData   The data sent by the user
  */
 public function createElements(array $formData)
 {
     // TODO(jom): Fetching already existing members to prevent the user from mistakenly creating duplicate
     // memberships (no matter whether the data source permits it or not, a member does never need to be
     // added more than once) should be kept at backend level (GroupController::fetchUsers) but this does
     // not work currently as our ldap protocol stuff is unable to handle our filter implementation..
     $members = $this->backend->select()->from('group_membership', array('user_name'))->where('group_name', $this->groupName)->fetchColumn();
     $filter = empty($members) ? Filter::matchAll() : Filter::not(Filter::where('user_name', $members));
     $users = $this->ds->select()->from('user', array('user_name'))->applyFilter($filter)->fetchColumn();
     if (!empty($users)) {
         $this->addElement('multiselect', 'user_name', array('multiOptions' => array_combine($users, $users), 'label' => $this->translate('Backend Users'), 'description' => $this->translate('Select one or more users (fetched from your user backends) to add as group member'), 'class' => 'grant-permissions'));
     }
     $this->addElement('textarea', 'users', array('required' => empty($users), 'label' => $this->translate('Users'), 'description' => $this->translate('Provide one or more usernames separated by comma to add as group member')));
     $this->setTitle(sprintf($this->translate('Add members for group %s'), $this->groupName));
     $this->setSubmitLabel($this->translate('Add'));
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:21,代码来源:AddMemberForm.php

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


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