Kohana 未定义的属性:请求::$action


Kohana Undefined property: Request::$action

我正在尝试使用本教程设置我的第一个Kohana网页 - http://kohana-tutorial.blogspot.co.uk/2010/10/lesson-1-getting-started.html

按照说明操作后,我留下了此错误 - 未定义的属性:请求::$action 在第 49 行。

这是与默认模板中的该行相关的代码.php

48   if (!$view){
49       $view = 'pages/'.$this->request->controller().'/'.$this->request->action.'_tpl';
50     }
51     $this->template->content = View::factory($view, $this->data);
52   }
53 }
54 ?> 

这是由 News.php 调用的,这是一个渲染某些内容的标准调用。

class Controller_News extends Controller_DefaultTemplate {
    public function  __construct('Request $request, 'Response $response) {
        parent::__construct($request, $response);
    }
    public function action_index(){
        $this->render();
    }
}

用于导致此错误的程序的完整列表是:

APPPATH/classes/Controller/DefaultTemplate.php [ 49 ] » Kohana_Core::error_handler(arguments)
APPPATH/classes/Controller/News.php [ 13 ] » Controller_DefaultTemplate->render()
SYSPATH/classes/Kohana/Controller.php [ 84 ] » Controller_News->action_index()
{PHP internal call} » Kohana_Controller->execute()
SYSPATH/classes/Kohana/Request/Client/Internal.php [ 97 ] » ReflectionMethod->invoke(arguments)
SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal-    >execute_request(arguments)
SYSPATH/classes/Kohana/Request.php [ 997 ] » Kohana_Request_Client->execute(arguments)
DOCROOT/index.php [ 118 ] » Kohana_Request->execute()APPPATH/classes/Controller/News.php [ 13 ] » Controller_DefaultTemplate->render()
SYSPATH/classes/Kohana/Controller.php [ 84 ] » Controller_News->action_index()
{PHP internal call} » Kohana_Controller->execute()
SYSPATH/classes/Kohana/Request/Client/Internal.php [ 97 ] » ReflectionMethod->invoke(arguments)
SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal->execute_request(arguments)
SYSPATH/classes/Kohana/Request.php [ 997 ] » Kohana_Request_Client->execute(arguments)
DOCROOT/index.php [ 118 ] » Kohana_Request->execute()

任何帮助将不胜感激。

本教程已有 4 年的历史,所以它可能有点过时了。

使用当前版本的 Kohana,您可以使用以下命令访问受保护的属性$request->_action

$this->request->action();

不要犹豫,查看在线文档甚至源代码 system/classes/Kohana ,它很清楚并且注释很好。