PHP 8.6.0 Beta 3 is available for testing

Yaf_Route_Map::__construct

(Yaf >=1.0.0)

Yaf_Route_Map::__constructConstruct a map route

Açıklama

publicfunction Yaf_Route_Map::__construct(bool $controller_prefer = false, string $delimiter = '')

Construct a map route. A map route maps the whole URI to a controller name or an action name.

Bağımsız Değişkenler

controller_prefer

Whether to map the URI to a controller name. If false, the URI is mapped to an action name.

delimiter

The delimiter used to separate the mapped name from the request parameters in the URI. If it occurs as a path segment preceded by a slash, everything after it is parsed as request parameters instead of being part of the mapped name. If empty, no such splitting happens during routing.

Dönen Değerler

No value is returned.

Örnekler

Örnek 1 Yaf_Route_Map example

<?php
/**
 * Add a map route to the Yaf_Router route stack
 */
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
    new Yaf_Route_Map());
?>

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

/* for http://yourdomain.com/product/foo/bar
 * the request will carry the following values:
 */
array(
  "action" => "product_foo_bar",
)

Örnek 2 Yaf_Route_Map example

<?php
/**
 * Add a map route with a delimiter to the Yaf_Router route stack
 */
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
    new Yaf_Route_Map(true, "_"));
?>

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

/* for http://yourdomain.com/user/list/_/foo/22
 * the request will carry the following values:
 */
array(
    "controller" => "User_List",
)

/**
 * and request parameters:
 */
array(
  "foo" => "22",
)

Örnek 3 Yaf_Route_Map example

<?php
/**
 * Add a map route to the route stack by calling addConfig
 */
$config = array(
    "name" => array(
       "type"             => "map", // Yaf_Route_Map route
       "controllerPrefer" => FALSE,
       "delimiter"        => "#!",
    ),
);
Yaf_Dispatcher::getInstance()->getRouter()->addConfig(
    new Yaf_Config_Simple($config));
?>

Ayrıca Bakınız

add a note

User Contributed Notes

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