Yaf_Plugin_Abstract::routerShutdown
(Yaf >=1.0.0)
Yaf_Plugin_Abstract::routerShutdown — The routerShutdown purpose
説明
public Yaf_Plugin_Abstract::routerShutdown
( Yaf_Request_Abstract
$request
, Yaf_Response_Abstract $response
) : voidこのフックが動くのは、ルーティングが終了したときです。 このフックは、ログインのチェックなどでよく使います。
警告
この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。
パラメータ
-
request -
-
response -
返り値
例
例1 Yaf_Plugin_Abstract::routerShutdown() の例
<?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->redirect("http://yourdomain.com/login/");
return FALSE;
}
?>
参考
- Yaf_Plugin_Abstract::routerStartup() - RouterStartup フック
- Yaf_Plugin_Abstract::dispatchLoopStartup() - Hook before dispatch loop
- Yaf_Plugin_Abstract::preDispatch() - The preDispatch purpose
- Yaf_Plugin_Abstract::postDispatch() - The postDispatch purpose
- Yaf_Plugin_Abstract::dispatchLoopShutdown() - The dispatchLoopShutdown purpose