私は少し問題がある、私はコントローラがAbstractActionControllerを拡張し、任意のアクション、例えばindexActionの前にいくつかの関数を呼び出す必要がある私はpreDispatch()が何らかのアクションの前に呼び出すと思うが、 this-> view-> testは何もありません。preDispatchが動作しない
あなたはより良いモジュールクラスでこれを行うには、このようなMVCイベントハンドラにEventManagerを使用したいclass TaskController extends AbstractActionController
{
private $view;
public function preDispatch()
{
$this->view->test = "test";
}
public function __construct()
{
$this->view = new ViewModel();
}
public function indexAction()
{
return $this->view;
}
}
私はGoogleでこれを発見しました。私はディスパッチで親に電話することを忘れました... – Ismael