Commit e59b2d89 by Qiang Xue

refactored rule execution. [skip ci]

parent a404e00b
...@@ -655,9 +655,6 @@ class DbManager extends Manager ...@@ -655,9 +655,6 @@ class DbManager extends Manager
*/ */
public function getRule($name) public function getRule($name)
{ {
if ($name === null) {
return null;
}
$query = new Query; $query = new Query;
$query->select(['data'])->from($this->ruleTable)->where(['name' => $name]); $query->select(['data'])->from($this->ruleTable)->where(['name' => $name]);
$row = $query->createCommand($this->db)->queryOne(); $row = $query->createCommand($this->db)->queryOne();
......
...@@ -151,6 +151,9 @@ abstract class Manager extends Component ...@@ -151,6 +151,9 @@ abstract class Manager extends Component
*/ */
public function executeRule($ruleName, $params, $data) public function executeRule($ruleName, $params, $data)
{ {
if ($ruleName === null) {
return true;
}
$rule = $this->getRule($ruleName); $rule = $this->getRule($ruleName);
if ($rule instanceof Rule) { if ($rule instanceof Rule) {
return $rule->execute($params, $data); return $rule->execute($params, $data);
......
...@@ -628,7 +628,7 @@ class PhpManager extends Manager ...@@ -628,7 +628,7 @@ class PhpManager extends Manager
*/ */
public function getRule($name) public function getRule($name)
{ {
return $name !== null && isset($this->_rules[$name]) ? $this->_rules[$name] : null; return isset($this->_rules[$name]) ? $this->_rules[$name] : null;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment