[英]Laravel Redirect::action() fallback?
As the documentation says the function Redirect::action()
receives a string which is separated into 2 parts by the symbol @
如文档所述,函数
Redirect::action()
接收一个字符串,该字符串由符号@
分成2部分。
eg Redirect::action('MyController@myFunction')
例如
Redirect::action('MyController@myFunction')
I've recently tried to give the function an input: Redirect::action('someRouteName')
and see what's gonna happen. 我最近尝试为函数输入:
Redirect::action('someRouteName')
,看看会发生什么。 Surprisingly it didn't return with an error but actually made the link just as if I was using the Redirect::route()
function (I had a route named as someRouteName
). 令人惊讶的是,它没有返回错误,但实际上建立了链接,就像我正在使用
Redirect::route()
函数(我的路由名为someRouteName
)一样。
Does the function Redirect::action()
falls back to Redirect::route()
if the value it gets is invalid? 如果函数
Redirect::action()
返回的值无效,它会退回到Redirect::route()
吗? Couldn't find any source that says that. 找不到任何这样的消息来源。
Yes, it does. 是的,它确实。 Some insight on it can be seen in sources.
在源代码中可以看到一些有关它的见解。
https://github.com/laravel/framework/blob/master/src/Illuminate/Routing/UrlGenerator.php#L455 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.