我想设置所有操作,因为当这些操作返回ViewModel类时,默认情况下会有参数setTerminal=true。
我希望我的应用程序有这种行为,因为我90%的调用都是AJAX。
提前谢谢。
检查创建和注册备用渲染和响应策略。http://framework.zend.com/manual/2.0/en/modules/zend.view.quick-start.html#creating-以及注册替代呈现和响应策略。
命名空间应用程序;
class Module
{
public function onBootstrap($e)
{
// Register a "render" event, at high priority (so it executes prior
// to the view attempting to render)
$app = $e->getApplication();
$app->getEventManager()->attach('render', array($this, 'registerJsonStrategy'), 100);
}
public function registerJsonStrategy($e)
{
$app = $e->getTarget();
$locator = $app->getServiceManager();
$view = $locator->get('Zend'View'View');
$jsonStrategy = $locator->get('ViewJsonStrategy');
// Attach strategy, which is a listener aggregate, at high priority
$view->getEventManager()->attach($jsonStrategy, 100);
}
}