[英]Laravel Redirect::action() fallback?
如文檔所述,函數Redirect::action()
接收一個字符串,該字符串由符號@
分成2部分。
例如Redirect::action('MyController@myFunction')
我最近嘗試為函數輸入: Redirect::action('someRouteName')
,看看會發生什么。 令人驚訝的是,它沒有返回錯誤,但實際上建立了鏈接,就像我正在使用Redirect::route()
函數(我的路由名為someRouteName
)一樣。
如果函數Redirect::action()
返回的值無效,它會退回到Redirect::route()
嗎? 找不到任何這樣的消息來源。
是的,它確實。 在源代碼中可以看到一些有關它的見解。
https://github.com/laravel/framework/blob/master/src/Illuminate/Routing/UrlGenerator.php#L455
/**
* Get the URL to a controller action.
*
* @param string $action
* @param mixed $parameters
* @param bool $absolute
* @return string
*/
public function action($action, $parameters = array(), $absolute = true)
{
return $this->route($action, $parameters, $absolute, $this->routes->getByAction($action));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.