【发布时间】:2026-02-07 00:50:01
【问题描述】:
我有一点问题,我有控制器扩展 AbstractActionController,我需要在任何操作之前调用一些函数,例如 indexAction 我认为 preDispatch() 在任何操作之前调用但是当我在 $this->view- 中尝试此代码时>测试什么都不是。
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;
}
}
【问题讨论】:
标签: zend-framework2