• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Yaf_Plugin_Abstract::routerShutdown()

    (Yaf >=1.0.0)

    The routerShutdown purpose

    说明

    publicYaf_Plugin_Abstract::routerShutdown(Yaf_Request_Abstract$request, Yaf_Response_Abstract$response): void

    这个钩子在路由结束之后触发,通常被用于登陆检查。

    Warning

    本函数还未编写文档,仅有参数列表。

    参数

    $request
    $response

    返回值

    范例

    Example #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->redirect("http://yourdomain.com/login/");
            return FALSE;
        }
    ?>
    

    参见

    • Yaf_Plugin_Abstract::routerStartup() RouterStartup hook
    • Yaf_Plugin_Abstract::dispatchLoopStartup() The dispatchLoopStartup purpose
    • Yaf_Plugin_Abstract::preDispatch() The preDispatch purpose
    • Yaf_Plugin_Abstract::postDispatch() The postDispatch purpose
    • Yaf_Plugin_Abstract::dispatchLoopShutdown() The dispatchLoopShutdown purpose