Yaf_Dispatcher::getRouter

(Yaf >=1.0.0)

Yaf_Dispatcher::getRouterRetrieve router instance

Description

public function Yaf_Dispatcher::getRouter(): ?Yaf_Router

Retrieve the Yaf_Router instance used by the dispatcher to route requests.

Parameters

This function has no parameters.

Return Values

The Yaf_Router instance, or null if the application is not initialized.

Examples

Example #1 Yaf_Dispatcher::getRouter() example

<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
    public function _initRoute(Yaf_Dispatcher $dispatcher)
    {
        $router = $dispatcher->getRouter();

        // Route /product/42 to ProductController::detailAction
        $router->addRoute("product", new Yaf_Route_Rewrite(
            "product/:id",
            array("controller" => "product", "action" => "detail")
        ));
    }
}
?>

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.