PHP 8.1.0 Beta 1 available for testing

Yaf_Plugin_Abstract::routerShutdown

(Yaf >=1.0.0)

Yaf_Plugin_Abstract::routerShutdownThe routerShutdown purpose

Açıklama

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

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

Değiştirgeler

request

response

Dönen Değerler

Örnekler

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

Ayrıca Bakınız

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top