是否有必要具有每个控制器操作的视图文件 [英] Is it necessary to have a view file with every controller action
问题描述
每当我使用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屋!