账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    YII2 如何书写并且配置在所有action请求之前和之后?
    29
    0

    这个是我的ActionTimeFilter 那么如何在web.php中配置才能启用每个action都会通过这个过滤器? 在线等,急急急 搞了一天了~ 有大牛吗

    <?php
    namespace app\filters;
    
    use Yii;
    use yii\base\Action;
    use yii\base\ActionFilter;
    
    class ActionTimeFilter extends ActionFilter
    {
        private $_startTime;
    
        public function beforeAction($action)
        {
            Yii::info('2222222222222');
            $this->_startTime = microtime(true);
            return array(
                'dd'=>2
            );
            return parent::beforeAction($action);
    //        return parent::beforeAction($action);
        }
    
        public function afterAction($action, $result)
        {
            $time = microtime(true) - $this->_startTime;
            Yii::debug("Action '{$action->uniqueId}' spent $time second.");
            \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
            return array(
                'dd'=>2
            );
    //        $time = microtime(true) - $this->_startTime;
    //        Yii::debug("Action '{$action->uniqueId}' spent $time second.");
    //        Yii::$app->response->format=Response::FORMAT_JSON;
            return parent::afterAction($action, $result);
        }
    }
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部