PHP 8.6.0 Beta 3 is available for testing

Yaf_Route_Static::route

(Yaf >=1.0.0)

Yaf_Route_Static::routeRoute a request

Açıklama

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.

Bağımsız Değişkenler

request

The Yaf_Request_Abstract instance to route.

Dönen Değerler

Always returns true.

Örnekler

Örnek 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"));
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

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

Ayrıca Bakınız

add a note

User Contributed Notes

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