我试图找出如何创建一个新的类或控制器,而不是覆盖现有的。所以我创建了控制器测试/controllers/front/TestController.php
class TestFrontController extends FrontController
{
public $php_self = 'test';
public function initContent()
{
parent::initContent();
echo "Test!";
}
}
但是,如果我去,mystore.com/index.php?controller=test
我会得到一个白页。在此之前我已经删除class_index.php
了cache
。
我还需要什么才能让我的新控制器工作?
ps 调试行说:
Fatal error: Class 'Test' not found in C:\LS\mystore\www\classes\controller\Controller.php on line 128
好吧,似乎每个控制器都必须有自己的类,但这可能不正确,因为我还创建了一个简单的测试类。这个类还必须有一个数据库表。
[
1. upd]
我做了一个测试表,类必须包含 $definitions 到它的字段,但仍然不知道为什么我不能运行脚本:
Fatal error: Call to undefined method Test::run() in C:\LS\mystore\www\classes\Dispatcher.php on line 348
这就是我的调试错误信息现在所说的。
[
2. upd]
我可以在我的Test类中添加一个Run方法,但是我觉得没有意义:
class TestCore extends ObjectModel
{
public $id_test;
protected $_test;
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'test',
'primary' => 'id_test',
'fields' => array(
'id_test' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
),
);
public function Run()
{
echo "Test!";
}
}
它只会显示Test!
,而不是内容和其他东西,其他类根本没有这个方法并且工作正常。
解决方案。一切都很好,我的覆盖/控制器/前端也有一个 test.php 文件,所以这就是原因。