解决了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来,赞!

0 thoughts on “解决了ZF的两个问题”

  1. Simply desire to say your article is as surprising.
    The clarity on your post is just nice and i could assume you’re a professional on this subject.
    Well along with your permission let me to grab your RSS feed to
    keep updated with imminent post. Thank you a million and please keep up the gratifying
    work.

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