zoukankan      html  css  js  c++  java
  • yii之behaviors

    BaseController:

        protected $actions = ['*'];
        protected $except = [];
        protected $mustlogin = [];
        protected $verbs = [];

        // 行为过滤
        public function behaviors()
        {
            return [
                'access' => [
                    'class' => yiifiltersAccessControl::className(),
                    'only' => $this->actions, // 针对哪些方法有效,默认所有
                    'except' => $this->except, // 针对哪些方法不进行控制
                    'rules' => [
                        [
                            'allow' => false,
                            'actions' => empty($this->mustlogin) ? [] : $this->mustlogin,
                            'roles' => ['?'] // 未登录用户默认均不可访问
                        ],
                        [
                            'allow' => true,
                            'actions' => empty($this->mustlogin) ? [] : $this->mustlogin,
                            'roles' => ['@'] // 登陆用户默认均可访问
                        ]
                    ]
                ],
                'verbs' => [
                    'class' => yiifiltersVerbFilter::className(),
                    'actions' => $this->verbs, // 针对某些方法限制其访问方式
                ]
            ];
        }
  • 相关阅读:
    2018年全国多校算法寒假训练营练习比赛(第二场)F
    牛客练习赛2 A
    牛客练习赛1 C
    牛客练习赛1 B
    vb编程代码大全
    javascript编程代码笔记
    391.FANUC宏程序编程
    宏程序编程实例,简单易懂
    Java类与类之间的关系详细介绍
    C++虚继承时的构造函数的讲解
  • 原文地址:https://www.cnblogs.com/maoriaty/p/9565354.html
Copyright © 2011-2022 走看看