From 5fda02398078dccd3b8aa93c8182891684784175 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 30 Jan 2016 23:20:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3traits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/traits/model/Adv.php | 3 --- library/traits/model/Auto.php | 29 +++++++++++++---------------- library/traits/model/View.php | 2 -- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/library/traits/model/Adv.php b/library/traits/model/Adv.php index 66c2b8ec..0a95841f 100644 --- a/library/traits/model/Adv.php +++ b/library/traits/model/Adv.php @@ -14,9 +14,6 @@ namespace traits\model; trait Adv { protected $optimLock = 'lock_version'; - //protected $serializeField = []; - //protected $readonlyField = []; - //protected $partition = []; /** * 利用__call方法重载 实现一些特殊的Model方法 (魔术方法) diff --git a/library/traits/model/Auto.php b/library/traits/model/Auto.php index 918d75f8..894db057 100644 --- a/library/traits/model/Auto.php +++ b/library/traits/model/Auto.php @@ -15,9 +15,6 @@ use think\Lang; trait Auto { - //protected $validate = []; // 自动验证定义 - //protected $auto = []; // 自动完成定义 - /** * 创建数据对象 但不保存到数据库 * @access public @@ -193,9 +190,9 @@ trait Auto // 检查填充条件 if ($flags & $type) { switch (trim($auto[3])) { - case 'function': // 使用函数进行填充 字段的值作为参数 - case 'callback': // 使用回调方法 - $args = isset($auto[4]) ? (array)$auto[4] : []; + case 'function': // 使用函数进行填充 字段的值作为参数 + case 'callback': // 使用回调方法 + $args = isset($auto[4]) ? (array) $auto[4] : []; if (is_string($auto[0]) && strpos($auto[0], ',')) { $auto[0] = explode(',', $auto[0]); } @@ -211,19 +208,19 @@ trait Auto if ('function' == $auto[3]) { $data[$auto[0]] = call_user_func_array($auto[1], $args); } else { - $data[$auto[0]] = call_user_func_array([& $this, $auto[1]], $args); + $data[$auto[0]] = call_user_func_array([ & $this, $auto[1]], $args); } break; - case 'field': // 用其它字段的值进行填充 + case 'field': // 用其它字段的值进行填充 $data[$auto[0]] = $data[$auto[1]]; break; - case 'ignore': // 为空忽略 + case 'ignore': // 为空忽略 if ($auto[1] === $data[$auto[0]]) { unset($data[$auto[0]]); } break; case 'string': - default: // 默认作为字符串填充 + default: // 默认作为字符串填充 $data[$auto[0]] = $auto[1]; } if (isset($data[$auto[0]]) && false === $data[$auto[0]]) { @@ -318,18 +315,18 @@ trait Auto } $val[3] = isset($val[3]) ? $val[3] : self::EXISTS_VALIDATE; $val[4] = isset($val[4]) ? $val[4] : 'regex'; - $status = true; + $status = true; // 判断验证条件 switch ($val[3]) { - case self::MUST_VALIDATE: // 必须验证 不管表单是否有设置该字段 + case self::MUST_VALIDATE: // 必须验证 不管表单是否有设置该字段 $status = $this->_validationFieldItem($data, $val); break; - case self::VALUE_VALIDATE: // 值不为空的时候才验证 + case self::VALUE_VALIDATE: // 值不为空的时候才验证 if ('' != trim($data[$val[0]])) { $status = $this->_validationFieldItem($data, $val); } break; - default: // 默认表单存在该字段就验证 + default: // 默认表单存在该字段就验证 if (isset($data[$val[0]])) { $status = $this->_validationFieldItem($data, $val); } @@ -358,7 +355,7 @@ trait Auto switch (strtolower(trim($val[4]))) { case 'function': // 使用函数进行验证 case 'callback': // 调用方法进行验证 - $args = isset($val[6]) ? (array)$val[6] : []; + $args = isset($val[6]) ? (array) $val[6] : []; if (is_string($val[0]) && strpos($val[0], ',')) { $val[0] = explode(',', $val[0]); } @@ -371,7 +368,7 @@ trait Auto } else { array_unshift($args, isset($data[$val[0]]) ? $data[$val[0]] : null); } - return call_user_func_array('function' == $val[4] ? $val[1] : [& $this, $val[1]], $args); + return call_user_func_array('function' == $val[4] ? $val[1] : [ & $this, $val[1]], $args); case 'confirm': // 验证两个字段是否相同 return $data[$val[0]] == $data[$val[1]]; case 'unique': // 验证某个值是否唯一 diff --git a/library/traits/model/View.php b/library/traits/model/View.php index 2a8b3d08..a84a7b8d 100644 --- a/library/traits/model/View.php +++ b/library/traits/model/View.php @@ -14,8 +14,6 @@ namespace traits\model; trait View { - protected $viewFields = []; - /** * 自动检测数据表信息 * @access protected