Commit e59b2d89 by Qiang Xue

refactored rule execution. [skip ci]

parent a404e00b
......@@ -655,9 +655,6 @@ class DbManager extends Manager
*/
public function getRule($name)
{
if ($name === null) {
return null;
}
$query = new Query;
$query->select(['data'])->from($this->ruleTable)->where(['name' => $name]);
$row = $query->createCommand($this->db)->queryOne();
......
......@@ -151,6 +151,9 @@ abstract class Manager extends Component
*/
public function executeRule($ruleName, $params, $data)
{
if ($ruleName === null) {
return true;
}
$rule = $this->getRule($ruleName);
if ($rule instanceof Rule) {
return $rule->execute($params, $data);
......
......@@ -628,7 +628,7 @@ class PhpManager extends Manager
*/
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