PHP 8.6.0 Beta 3 is available for testing

Yaf_Route_Static::route

(Yaf >=1.0.0)

Yaf_Route_Static::routeRoute a request

Beschreibung

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

Route the request according to the PATH_INFO style URI: the first path segment is treated as the module name only if it is one of the registered modules, otherwise the segments are mapped to the controller and the action in order. The remaining segments become request parameters.

For example, with no module named foo, /foo/bar/age/10 routes to the controller Foo, the action bar, with a parameter age of 10.

Parameter-Liste

request

The Yaf_Request_Abstract instance to route.

Rückgabewerte

Always returns true.

Beispiele

Beispiel #1 Yaf_Route_Static::route() example

<?php
$request = new Yaf_Request_Http("/product/detail/id/10");

/* the static route is the default route of Yaf_Router,
 * registered under the name "_default" */
$route = Yaf_Dispatcher::getInstance()->getRouter()->getRoute("_default");
var_dump($route->route($request));

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

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

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

Siehe auch

add a note

User Contributed Notes

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