本文整理匯總了PHP中Illuminate\Routing\Router::setCurrentRoute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Router::setCurrentRoute方法的具體用法?PHP Router::setCurrentRoute怎麽用?PHP Router::setCurrentRoute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Routing\Router
的用法示例。
在下文中一共展示了Router::setCurrentRoute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: invoke
/**
* Call internal URI with parameters.
*
* @param string $uri
* @param string $method
* @param array $parameters
* @return mixed
*/
public function invoke($uri, $method, $parameters = array())
{
// Request URI.
$uri = '/' . ltrim($uri, '/');
// Parameters for GET, POST
$parameters = $parameters ? current($parameters) : array();
try {
// store the original request data and route
$originalInput = $this->request->input();
$originalRoute = $this->router->getCurrentRoute();
// create a new request to the API resource
$request = $this->request->create($uri, strtoupper($method), $parameters);
// replace the request input...
$this->request->replace($request->input());
$dispatch = $this->router->dispatch($request);
if (method_exists($dispatch, 'getOriginalContent')) {
$response = $dispatch->getOriginalContent();
} else {
$response = $dispatch->getContent();
}
// Decode json content.
if ($dispatch->headers->get('content-type') == 'application/json') {
if (function_exists('json_decode') and is_string($response)) {
$response = json_decode($response, true);
}
}
// replace the request input and route back to the original state
$this->request->replace($originalInput);
$this->router->setCurrentRoute($originalRoute);
return $response;
} catch (NotFoundHttpException $e) {
}
}