dsifjgogw48491752 2014-06-01 20:18
浏览 82

Laravel 4 - 调用未定义的方法SomeController :: getAfterFilters()

I get

Call to undefined method ContestsCpController::getAfterFilters()

on a specific controller. All other controllers are working fine and I do not remember any change that would cause this breakage. In fact, I haven't touched the code in weeks. The last thing I did was some refactoring.

Route

Route::get("contestscp/home", "ContestsCpController@getHome");

Controller

<?php

class ContestsCpController extends BaseController
{

    public function getHome() {
        return Redirect::to("contestscp/give_award");
    }
...
some other methods
...
}
?>

Debug output

/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @param string $method
* @return mixed
*/
protected function assignAfter($instance, $route, $request, $method)
{
foreach ($instance->getAfterFilters() as $filter) //fails here
{
// If the filter applies, we will add it to the route, since it has already been

Google and SO suggest that this is caused when controller does not extend BaseController but this is obviously not the case. So I assume that for some reason my class is not being extended. Or.. the class fails to initialize and $instance is null. But I have no idea why and how to debug this.

Any suggestions?

  • 写回答

1条回答 默认 最新

  • dongrang9300 2014-06-01 21:42
    关注

    I knew this had to be something stupid.. because it always is.

    The problem was my refactoring. I used to have all validators extended in a single file. When I separated the validators into different files I misnamed my ContestsCpValidator class as ContestsCPController (duh..). So I had a second class with the same name with no methods obviously.

    So basically, if you happen to have this error and you are indeed extending the BaseController make sure you don't autoload another class with the same name.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测