GoLang Yaf_Plugin_Abstract::routerShutdown

request it (383)
GoLang replacement for PHP's Yaf_Plugin_Abstract::routerShutdown [edit | history]



Do you know a GoLang replacement for PHP's Yaf_Plugin_Abstract::routerShutdown? Write it!

PHP Yaf_Plugin_Abstract::routerShutdown

PHP original manual for Yaf_Plugin_Abstract::routerShutdown [ show | php.net ]

Yaf_Plugin_Abstract::routerShutdown

(Yaf >=1.0.0)

Yaf_Plugin_Abstract::routerShutdownThe routerShutdown purpose

Description

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

This hook will be trigged after the route process finished, this hook is usually used for login check.

Warning

This function is currently not documented; only its argument list is available.

Parameters

request

response

Return Values

Examples

Example #1 Yaf_Plugin_Abstract::routerShutdown()example

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

See Also