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


PHP Rule::factory方法代码示例

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


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

示例1: load

 /**
  * @param KnowledgeBase $knowledgeBase
  */
 public function load(KnowledgeBase $knowledgeBase)
 {
     foreach ($this->data['facts'] as $name => $value) {
         $knowledgeBase->add(Fact::factory($name, $value));
     }
     foreach ($this->data['rules'] as $condition => $data) {
         if (is_string($data)) {
             $action = $data;
             $priority = 0;
         } else {
             $action = $data['action'];
             $priority = isset($data['priority']) ? $data['priority'] : 0;
         }
         $knowledgeBase->add(Rule::factory($condition, $condition, $action, $priority));
     }
 }
开发者ID:javihgil,项目名称:php-expert-system,代码行数:19,代码来源:KnowledgeJsonLoader.php

示例2: execute

 public function execute()
 {
     $this->context->pseudo_args($this->args);
     // Create a rule
     $rule = Rule::factory($this->context, $this->callback, $this->args);
     // Execute the rule, and if no errors are returned, perform the actions
     if ($rule->execute() === $this->check_against) {
         // Use the parent for executing actions
         $parent = $this->context->parent(Formo::PARENT);
         foreach ($this->action_fields as $key => $field) {
             // Fix the args
             $this->context->pseudo_args($this->action_args[$key]);
             // Perform each action
             $callback = array($parent->find($field), $this->action_callbacks[$key]);
             call_user_func_array($callback, $this->action_args[$key]);
         }
     }
 }
开发者ID:justus,项目名称:kohana-formo,代码行数:18,代码来源:core.php

示例3: rule

 public function rule($field, $callback, array $args = NULL)
 {
     $context = $field = $field === NULL ? $this : $this->find($field);
     $this->make_context($context, $callback);
     // Add the rule
     $field->add_validator('rules', Rule::factory($field, $context, $callback, $args));
     return $this;
 }
开发者ID:vitch,项目名称:kohana-formo,代码行数:8,代码来源:core.php


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