PHP 8.6.0 Beta 3 is available for testing

Yaf_Route_Simple::route

(Yaf >=1.0.0)

Yaf_Route_Simple::routeRoute a request

Description

public function Yaf_Route_Simple::route(Yaf_Request_Abstract $request): bool

Route the request with query parameters: the module, controller and action names are retrieved from the query variables named as the ones given to the constructor.

Parameters

request

The Yaf_Request_Abstract instance to route.

Return Values

Returns true if any of the three query variables is present, false otherwise, which makes the router try the next route.

Examples

Example #1 Yaf_Route_Simple::route() example

<?php
/* assume the request was made with
 * http://yourdomain.com/index.php?m=main&c=product&a=detail */
$request = new Yaf_Request_Http("/index.php");

$route = new Yaf_Route_Simple("m", "c", "a");
var_dump($route->route($request));

var_dump($request->getModuleName());
var_dump($request->getControllerName());
var_dump($request->getActionName());
?>

The above example will output something similar to:

bool(true)
string(4) "main"
string(7) "product"
string(6) "detail"

See Also

add a note

User Contributed Notes

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