From 2e9be1464d23532b350f78691cb910e1bcb0b464 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 8 May 2015 09:03:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=AE=80=E5=8D=95=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=89=8D=E7=BD=AE=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/controller.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/think/controller.php b/library/think/controller.php index b178804b..1bf83062 100644 --- a/library/think/controller.php +++ b/library/think/controller.php @@ -32,11 +32,12 @@ class Controller { // 前置操作方法 $list = Config::get('before_action_list'); if($list){ - foreach($list as $config){ - $this->beforeAction($config['method',$config['option']); + foreach($list as $method=>$options){ + is_numeric($method)? + $this->beforeAction($options): + $this->beforeAction($method,$options); } } - } /** @@ -45,7 +46,7 @@ class Controller { * @param string $method 前置操作方法名 * @param array $options 调用参数 ['only'=>[...]] 或者['except'=>[...]] */ - protected function beforeAction($method, $options) { + protected function beforeAction($method, $options=[]) { if (isset($options['only'])) { if (!in_array(ACTION_NAME, $options['only'])) { return;