解决了ZF的两个问题

  之前提到Zend Framework的三个问题,有两个问题今天晚上搞明白了。

  • ErrorController官方文档里面提到的_getRequest(‘error_handler’)方法不存在的问题,改成 $this->_getParam(‘error_handler’)即可解决。
  • Controller里面的init()方法会在基类的构造函数__construct()之前调用的问题,通过阅读 Zend_Controller_Action类里面的100-130行找到解决办法,就是在基类的__construct()里面,把 parent::__construct($request, $response, $invokeArgs); 移到初始化操作之后,比如__construct()的最后一行即可解决。

  第三个关于 useDefaultControllerAlways 参数导致_forward()方法的controller参数失效的问题不是太紧急,回头再研究。

  顺便提一下,ZF的Router功能实在太强大了,甚至支持正则匹配,完全可以写出任何你想要的灵活的URL来,赞!

Category: PHP / Zend  Tags: , ,
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image