Php Yii控制器继承(在子模块中)

Php Yii控制器继承(在子模块中),php,inheritance,yii,controller,Php,Inheritance,Yii,Controller,我的问题是,如何在YII中继承控制器操作,例如: class MainController extends FController { public function ActionIndex() { $this->render("index"); //the view; } } -------------------------------------------- class SecondController extends FController { publ

我的问题是,如何在YII中继承控制器操作,例如:

class MainController extends FController
{
  public function ActionIndex()
  {
    $this->render("index"); //the view;
  }
}

--------------------------------------------
class SecondController extends FController
{
  public function ActiondIndex()
  {
   MainController::ActionIndex();   
  }
}

实际上,在我的例子中,SecondController是子模块的DefaultController。我想创建基于单个代码的网页。

由于PHP不支持多重继承,您可以通过parent关键字访问基类

class MainController extends FController
{
  public function ActionIndex()
  {
    $this->render("index"); //the view;
  }
}

class SecondController extends FController
{
  public function ActionIndex() // Note: you mistyped the name of this action in your example
  {
    parent::ActionIndex();   
  }
}
尽管您无法直接访问祖父母的
ActionIndex
方法,但您必须为此创建一个变通方法