=1.0.0)Yaf_Plugin_Abstract::routerShutdown — The routerShutdown purpose說(shuō)明public Yaf_Plugin_Abstract::routerSh">
(Yaf >=1.0.0)
Yaf_Plugin_Abstract::routerShutdown — The routerShutdown purpose
$request
, Yaf_Response_Abstract $response
): void這個(gè)鉤子在路由結(jié)束之后觸發(fā),通常被用于登陸檢查。
request
response
示例 #1 Yaf_Plugin_Abstract::routerShutdown()example
<?php
class UserInitPlugin extends Yaf_Plugin_Abstract {
public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {
$controller = $request->getControllerName();
/**
* Use access controller is unecessary for APIs
*/
if (in_array(strtolower($controller), array(
'api',
))) {
return TRUE;
}
if (Yaf_Session::getInstance()->has("login")) {
return TRUE;
}
/* Use access check failed, need to login */
$response->setRedirect("http://yourdomain.com/login/");
return FALSE;
}
?>