Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1548662
  • 博文数量: 194
  • 博客积分: 6450
  • 博客等级: 准将
  • 技术积分: 2085
  • 用 户 组: 普通用户
  • 注册时间: 2005-06-06 13:39
文章分类

全部博文(194)

文章存档

2013年(38)

2012年(11)

2011年(1)

2010年(1)

2009年(4)

2008年(13)

2007年(18)

2006年(63)

2005年(45)

我的朋友

分类: 系统运维

2007-07-13 09:38:10

ZF1.0 终于释出, 于是尝试用ZF构建一个简易的CMS.
以前也多少看了一些预览版本, 由于变化过大, 都没有试用过,
一直等到今天正式版本(其实等了很久的)
也没有注意Action Helper中是否内置了ViewRender,
今次的试用发现了这个视图显示帮助器.
 
我没有很仔细的研读手册,
当我在Action Controller 中执行render方法后,
总是显示重复的视图.
当我注释掉控制器中视图显示相关的方法后,
消失了一个。
 
翻阅手册发现Action Helper内置了一个ViewRender.
手册上如是曰:

The ViewRenderer helper is designed to satisfy the following goals:
[ViewRenderer被设计来满足如下的目标: ]

1, Eliminate the need to instantiate view objects within controllers;
view objects will be automatically registered with the controller.
[消除在控制器中实例化视图对象的必要; 视图对象将自动地在控制器中注册.]

2, Automatically set view script, helper, and filter paths based on the current module,
and automatically associate the current module name as a class prefix for helper and filter classes.
[基于当前的module, 自动地设置视图 script, helper, filter 路径, 自动的关联当前的module名作为 helper和filter类的类前缀.]

3, Create a globally available view object for all dispatched controllers and actions.
[为所有分配的控制器和行为 创建一个全局可用的视图对象。]

4, Allow the developer to set default view rendering options for all controllers.
[允许开发者为所有的控制器设置默认的视图显示选项.]

5, Add the ability to automatically render a view script with no intervention.
[添加了自动显示视图脚本的能力。]

6, Allow the developer to create her own specifications for the view base path and for view script paths.
[允许开发者按照自己的需求创建视图基路径和视图脚本路径.]


看来ZF为我们开发者考虑了很多哦。如果你想关闭这项功能,可如下操作。

// Baz controller class, bar module:
class Bar_BazController extends Zend_Controller_Action
{
    public function fooAction()
    {
        // Don't auto render this action
        $this->_helper->viewRenderer->setNoRender();
    }
}

// Bat controller class, bar module:
class Bar_BatController extends Zend_Controller_Action
{
    public function preDispatch()
    {
        // Never auto render this controller's actions
        $this->_helper->viewRenderer->setNoRender();
    }
}
?>

后记:和先前的预览版本相比有很多功能上的增加,也修正了很多BUG, 性能应该有也一定的提升.
手册和API文档已经从核心包中分离出来,有种瘦身的感觉。
相信这个来自PHP精英团队,堪称工业级的框架将极大的改善PHP开发体验,并将促进PHP5的应用.

阅读(1203) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~