PHP 8.6.0 Beta 3 is available for testing

Yaf_Route_Static::route

(Yaf >=1.0.0)

Yaf_Route_Static::routeRoute a request

Опис

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.

Параметри

request

The Yaf_Request_Abstract instance to route.

Значення, що повертаються

Always returns true.

Приклади

Приклад #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"));
?>

Поданий вище приклад виведе щось схоже на:

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

Прогляньте також

add a note

User Contributed Notes

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