每个控制器动作都需要一个视图文件吗 [英] Is it necessary to have a view file with every controller action

查看:17
本文介绍了每个控制器动作都需要一个视图文件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我使用 zf CLI 工具在 zend 框架控制器中创建新操作时,它都会创建相应的视图文件.但是,我不需要控制器中每个操作的视图文件.

Whenever I create a new action in the zend framework controller using the zf CLI tool it creates the corresponding view file. However, I don't need the view file for every action in the controller.

如果我手动删除该视图文件,它会影响我的 project.xml 文件还是对我的项目有任何其他影响?

If I delete that view file manually will it affect my project.xml file or have any other effect on my project ?

推荐答案

不,你不需要.

自从我使用 Zend Framework 以来已经有一段时间了.但如果我没记错的话,这里有两个选择.

Been a while since i worked with Zend Framework. But if memory serves me well, you have two options here.

1 - $this->_helper->viewRenderer->setNoRender(true);这将停止渲染视图

1 - $this->_helper->viewRenderer->setNoRender(true); Which will stop the view being rendered

2- 您可以简单地做您需要做的事情,并在您的操作结束时调用 exit().

2- You can simply do what you need to do and call exit() in the end of the of your action.

希望有帮助.

干杯

这篇关于每个控制器动作都需要一个视图文件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆