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行使内容请搜刮剧本之家早年的文章或继承赏识下面的相干文章但愿各人往后多多支持剧本之家! (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |