Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_Plugin_Abstract::preResponseYaf_Plugin_Abstract::routerStartup>
^Yaf_Plugin_AbstractLast updated: Mon, 26 Oct 2026

Yaf_Plugin_Abstract::routerShutdown

(Yaf >=1.0.0)

Yaf_Plugin_Abstract::routerShutdown — Hook after routing

Description

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

This hook is triggered after the routing process has finished and the controller and action names have been resolved, but before the dispatch loop starts. It is usually used for access control checks such as a login check, because the target controller and action are already known.

Parameters

request

The Yaf_Request_Abstract instance being dispatched.

response

The Yaf_Response_Abstract instance.

Return Values

No value is returned.

Examples

Example #1 Yaf_Plugin_Abstract::routerShutdown() example

<?php
class AuthPlugin extends Yaf_Plugin_Abstract
{
    public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {
        /* routing is done, so the target controller and action are
         * known: check whether the user may access them */
        $public = array("Index" => array("index"), "User" => array("login"));

        $controller = $request->getControllerName();
        $action = $request->getActionName();

        if (isset($public[$controller]) && in_array($action, $public[$controller])) {
            return;
        }

        if (!Yaf_Session::getInstance()->has("login")) {
            $response->setRedirect("/user/login");
            $request->setDispatched(true); // do not dispatch the request
        }
    }
}

/* plugins are registered in the bootstrap */
class Bootstrap extends Yaf_Bootstrap_Abstract
{
    public function _initPlugin(Yaf_Dispatcher $dispatcher)
    {
        $dispatcher->registerPlugin(new AuthPlugin());
    }
}
?>

See Also


<Yaf_Plugin_Abstract::preResponseYaf_Plugin_Abstract::routerStartup>
^Yaf_Plugin_AbstractLast updated: Mon, 26 Oct 2026