本文整理汇总了PHP中rest::request_method方法的典型用法代码示例。如果您正苦于以下问题:PHP rest::request_method方法的具体用法?PHP rest::request_method怎么用?PHP rest::request_method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rest
的用法示例。
在下文中一共展示了rest::request_method方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
/**
* Handle dispatching for all REST controllers.
*/
public function __call($function, $args)
{
// If no parameter was provided after the controller name (eg "/albums") then $function will
// be set to "index". Otherwise, $function is the first parameter, and $args are all
// subsequent parameters.
$request_method = rest::request_method();
if ($function == "index" && $request_method == "get") {
return $this->_index();
}
$resource = ORM::factory($this->resource_type, $function);
if (!$resource->loaded && $request_method != "post") {
return Kohana::show_404();
}
if ($request_method != "get") {
access::verify_csrf();
}
switch ($request_method) {
case "get":
return $this->_show($resource);
case "put":
return $this->_update($resource);
case "delete":
return $this->_delete($resource);
case "post":
return $this->_create($resource);
}
}
示例2: request_method_test
public function request_method_test()
{
foreach (array("GET", "POST") as $method) {
foreach (array("", "PUT", "DELETE") as $tunnel) {
if ($method == "GET") {
$expected = "GET";
} else {
$expected = $tunnel == "" ? $method : $tunnel;
}
$_SERVER["REQUEST_METHOD"] = $method;
$_POST["_method"] = $tunnel;
$this->assert_equal(strtolower(rest::request_method()), strtolower($expected), "Request method: {$method}, tunneled: {$tunnel}");
}
}
}