traits层次调整去掉 think目录 用户自定义的traits可以放到模块目录下面区分

This commit is contained in:
thinkphp
2015-12-11 20:39:48 +08:00
parent b176949a7a
commit 46c0f4fe84
7 changed files with 25 additions and 23 deletions

View File

@@ -1,17 +1,17 @@
<?php
<?php
/**
* 用法:
* T('think/controller/ajax');
* T('controller/ajax');
* class index
* {
* use \traits\think\controller\ajax;
* use \traits\controller\ajax;
* public function index(){
* $this->result();
* }
* }
*/
namespace traits\think\controller;
use think\Config;
namespace traits\controller;
trait Ajax
{
@@ -64,4 +64,4 @@ trait Ajax
return $this->result('', $message, 1, $jumpUrl, $wait);
}
}
}

View File

@@ -1,23 +1,25 @@
<?php
<?php
/**
* 用法:
* T('think/controller/view');
* T('controller/view');
* class index
* {
* use \traits\think\controller\view;
* use \traits\controller\view;
* public function index(){
* $this->assign();
* $this->show();
* }
* }
*/
namespace traits\think\controller;
namespace traits\controller;
use think\Config;
trait View
{
// 视图类实例
protected $view = null;
protected $view = null;
/**
* 架构函数 初始化视图类 并采用内置模板引擎
@@ -26,8 +28,8 @@ trait View
public function initView()
{
// 模板引擎参数
if(is_null($this->view)){
$this->view = new \think\View(Config::get()); // 只能这样写不然view会冲突
if (is_null($this->view)) {
$this->view = new \think\View(Config::get()); // 只能这样写不然view会冲突
}
}
@@ -125,4 +127,4 @@ trait View
return $this->result('', $message, 1, $jumpUrl, $wait);
}
}
}

View File

@@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace traits\think\model;
namespace traits\model;
use think\Lang;
use think\Loader;

View File

@@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace traits\think\model;
namespace traits\model;
define('EXISTS_VALIDATE', 0);
define('MUST_VALIDATE', 1);
@@ -62,8 +62,8 @@ trait Auto
$fields = explode(',', $fields);
}
// 判断令牌验证字段
if (C('TOKEN_ON')) {
$fields[] = C('TOKEN_NAME');
if (Config::get('token_on')) {
$fields[] = Config::get('token_name');
}
foreach ($data as $key => $val) {

View File

@@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace traits\think\model;
namespace traits\model;
trait Query
{

View File

@@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace traits\think\model;
namespace traits\model;
define('HAS_ONE', 1);
define('BELONGS_TO', 2);
@@ -288,7 +288,7 @@ trait Relation
$pk = $model->getPk();
foreach ($mappingData as $vo) {
if (isset($vo[$pk])) {
// 更新数据
// 更新数据
$mappingCondition = "$pk ={$vo[$pk]}";
$result = $model->where($mappingCondition)->save($vo);
} else {

View File

@@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace traits\think\model;
namespace traits\model;
trait View
{
@@ -92,7 +92,7 @@ trait View
private function _checkFields($name, $fields)
{
if (false !== $pos = array_search('*', $fields)) {
// 定义所有字段
// 定义所有字段
$fields = array_merge($fields, M($name)->getDbFields());
unset($fields[$pos]);
}