php8.5
Home/ Manual/ yaf / yaf_route_supervar/ Yaf_Route_Supervar::route

Yaf_Route_Supervar::route

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Route a request

Description

Yaf_Route_Supervar::route(Yaf_Request_Abstract $request): bool

Route the request with a super variable: the query variable named as the one given to the constructor is expected to carry a PATH_INFO style URI, which is then parsed like Yaf_Route_Static does.

Parameters

request

The Yaf_Request_Abstract instance to route.

Return Values

Returns true if the variable is present and holds a string, false otherwise, which makes the router try the next route.

Examples

Yaf_Route_Supervar::route example

php
<?php
/* assume the request was made with
 * http://yourdomain.com/index.php?_url=/product/detail/id/10 */
$request = new Yaf_Request_Http("/index.php");

$route = new Yaf_Route_Supervar("_url");
var_dump($route->route($request));

var_dump($request->getControllerName());
var_dump($request->getActionName());
var_dump($request->getParam("id"));
?>

The above example will output something similar to:

output
bool(true)
string(7) "product"
string(6) "detail"
string(2) "10"

See Also

  • Yaf_Route_Supervar::__construct
  • Yaf_Route_Supervar::assemble

Source: reference/yaf/yaf_route_supervar/route.xml · from the official PHP manual (php/doc-en)