Yaf_Plugin_Abstract::routerShutdown

The routerShutdown purpose

説明

public void Yaf_Plugin_Abstract::routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)

このフックが動くのは、ルーティングが終了したときです。 このフックは、ログインのチェックなどでよく使います。

パラメータ

request

response

戻り値

例1 Yaf_Plugin_Abstract::routerShutdown の例

<?php
class UserInitPlugin extends Yaf_Plugin_Abstract {

    public function 
routerShutdown(Yaf_Request_Abstract $requestYaf_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;
    }
}
?>

参考

  • Yaf_Plugin_Abstract::routerStartup
  • Yaf_Plugin_Abstract::dispatchLoopStartup
  • Yaf_Plugin_Abstract::preDispatch
  • Yaf_Plugin_Abstract::postDispatch
  • Yaf_Plugin_Abstract::dispatchLoopShutdown