升级到5.1.28版本

This commit is contained in:
巴掌 committed 2018-11-01 09:01:46 +08:00
1 parent 4bc2bfa35a
commit 81d9f5e5e5
23 files changed
+321 -150

No files matched your search

+30 -29
View File
@@ -67,35 +67,6 @@ class Controller
// 控制器初始化
$this->initialize();
// 控制器中间件
if ($this->middleware) {
foreach ($this->middleware as $key => $val) {
if (!is_int($key)) {
$only = $except = null;
if (isset($val['only'])) {
$only = array_map(function ($item) {
return strtolower($item);
}, $val['only']);
} elseif (isset($val['except'])) {
$except = array_map(function ($item) {
return strtolower($item);
}, $val['except']);
}
if (isset($only) && !in_array($this->request->action(), $only)) {
continue;
} elseif (isset($except) && in_array($this->request->action(), $except)) {
continue;
} else {
$val = $key;
}
}
$this->app['middleware']->controller($val);
}
}
// 前置操作方法 即将废弃
foreach ((array) $this->beforeActionList as $method => $options) {
is_numeric($method) ?
@@ -108,6 +79,36 @@ class Controller
protected function initialize()
{}
// 注册控制器中间件
public function registerMiddleware()
{
foreach ($this->middleware as $key => $val) {
if (!is_int($key)) {
$only = $except = null;
if (isset($val['only'])) {
$only = array_map(function ($item) {
return strtolower($item);
}, $val['only']);
} elseif (isset($val['except'])) {
$except = array_map(function ($item) {
return strtolower($item);
}, $val['except']);
}
if (isset($only) && !in_array($this->request->action(), $only)) {
continue;
} elseif (isset($except) && in_array($this->request->action(), $except)) {
continue;
} else {
$val = $key;
}
}
$this->app['middleware']->controller($val);
}
}
/**
* 前置操作
* @access protected