Yii中特殊行为ActionFilter的使用方法示例
短视频,自媒体,达人种草一站服务 这篇文章主要给大家介绍了关于Yii中特殊行为ActionFilter的使用方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 #FormatStrongID_0# LoggingFilter 的功能: 在指定请求的 action 前后各记录一条日志 <?php namespace appfilters; use yiibaseActionFilter; class LoggingFilter extends ActionFilter // To do something return true; public function afterAction($action, $result) // To do something return true; 新建 appcontrollersSystemController <?php namespace appcontrollers; use appfiltersLoggingFilter; class SystemController extends yiiwebController return [ public function actionTestOne() public function actionTestTwo() public function actionTest() #FormatStrongID_1# 请求 ?r=system/test This is a logging for testbeforeAction. 请求 ?r=system/test-one This is a testing for system/test-one. 请求 ?r=system/test-two This is a testing for system/test-two. Yii中特殊行为ActionFilter的使用方法示例 #FormatStrongID_2# Yii 中的 ActionFilter(过滤器)相当于 Laravel 中的 Middleware(中间件),beforeAction 相当于前置中间件,afterAction 相当于后置中间件。 到此这篇关于Yii中特殊行为ActionFilter使用的文章就介绍到这了,更多相关Yii特殊行为ActionFilter使用内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家! (编辑:青岛站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |