问题描述
我使用的是Laravel 5.1中的 Intercept Laravel Routing 问题的解决方案,并将其更新为5.2,他们删除了创建自定义调度程序的功能.
I was using the solution to the Intercept Laravel Routing question in Laravel 5.1 and with the update to 5.2, they removed the ability create custom dispatchers.
有人找到创建版本化方法的替代方法吗?
Have someone find an alternative to create versioned methods?
推荐答案
虽然不如自定义调度程序强大(我找不到删除它的理由),但是您可以覆盖 callAction
方法. ControllerDispatcher::call
.
While not as powerful as a custom dispatcher (I couldn't find the reasoning for its removal), you can override the callAction
method in your controllers. This method is called is called by ControllerDispatcher::call
.
不幸的是,此方法不会更改用于解析类型提示参数的方法,因为这取决于传递给分派器的方法名称,我看不到有替代方法,但是确实保留了标准路由参数的完整性. ,因此您仍然可以自己加载依赖项(通过app()->make(Dependency::class)
).
Unfortunately, this method does not change the method used to resolve type-hinted parameters, as that depends on the method name passed to the dispatcher, which I do not see a way to override, but does keep the standard route parameters intact, so you can still load dependencies by yourself (via app()->make(Dependency::class)
).
这篇关于Laravel:定制调度程序的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!