有undispatchable不逞多让有这个词吗吗?

文章责编:gaoxiaoliang& 看了本文的网友还看了
?&&( 17:25:00)?&&( 16:45:00)?&&( 10:23:00)?&&( 13:02:00)?&&( 16:22:00)?&&( 15:43:00)?
? ?   ? ?   ? ?   ? ?   ? ?
? ?   ? ?   ?
?   ? ?    ? ?   ? ?   ? ?   ? ?
? ?   ? ?
|     |
|     |
|     |
|     |
|     |
精选推荐专题 |
|        |
实用工具 |
| 大全 | 大全     |
版权声明:如果网所转载内容不慎侵犯了您的权益,请与我们联系,我们将会及时处理。如转载本内容,请注明出处。
Copyright & 2004-
 考试网 All Rights Reserved 
中国科学院研究生院权威支持(北京) 电 话:010- 传 真:010-君,已阅读到文档的结尾了呢~~
《红字》的论文
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
《红字》的论文
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口Zend Framework 1 - How to detect routing errors from within a plugin at routeShutdown - Stack Overflow
Join the Stack Overflow Community
Stack Overflow is a community of 7.1 million programmers, just like you, helping each other.
J it only takes a minute:
Zend Framework 1.11.11
I am writing a Zend Framework Controller Plugin that does stuff in the routeShutdown hook.
I'd like to be able to avoid running my processes if there are routing errors.
i.e. I do not want to run the processes if we are just gonna get a 404 error.
class MyPlugin extends Zend_Controller_Plugin_Abstract
public function routeShutdown( Zend_Controller_Request_Abstract $zfRequestObj )
if ( $this-&isRoutingError() )
//there was a routing error do not do any intensive page start up stuff
return $this-&doRouteShutdownProcesses( $zfRequestObj );
protected function isRoutingError()
//?? So how do we get this?
So, how can we determine if there was a routing error at this point?
Things I have tried.
Check the module, controller, action name in the requestObj
Does not work cos that is not set to Error Action yet
Check for exceptions in response object
Does not work cos $this-&getResponse()-&isException() seems to return FALSE, even when there was a routing error.
Any help appreciated.
2,40933052
I have worked it out myself.
I was being stupid. At routeShutdown we do not know whether its going to be a 404 page type error until we try to dispatch it.
So all we can do is
test for general exceptions in the response
ask the dispatcher if the route is likely to be Dispatchable.
So the plugin cannot really determine if there is a 'routing error' - so it has to ask "isRouteShutdownToBeSkipped()" :
class MyPlugin extends Zend_Controller_Plugin_Abstract
public function routeShutdown( Zend_Controller_Request_Abstract $zfRequestObj )
if ( $this-&isRouteShutdownToBeSkipped( $zfRequestObj ) )
//do not do any intensive page start up stuff
return $this-&doRouteShutdownProcesses( $zfRequestObj );
Then the isRouteShutdownToBeSkipped() method tests for
general exceptions, or for
undispatchable controllers
action methods that do not exist. (I avoid using magic in my project, so I know that if the method aint declared, then it aint gonna work.)
class MyPlugin extends Zend_Controller_Plugin_Abstract
protected function isRouteShutdownToBeSkipped( Zend_Controller_Request_Abstract $zfRequestObj )
if ( $this-&getResponse()-&isException() )
//Skip cos there was an exception already.
return TRUE;
if (!( $this-&isDispatchable( $zfRequestObj ) ))
//Skip cos route is not dispatchable (i.e no valid controller found).
return TRUE;
if (!( $this-&actionMethodExists( $zfRequestObj ) ))
//There is no action method on the controller class that
//resembles the requested action.
return TRUE;
//else else give it a go
return FALSE;
My isDispatchable() method simply delegates to the dispatcher:
class MyPlugin extends Zend_Controller_Plugin_Abstract
protected function isDispatchable( Zend_Controller_Request_Abstract $zfRequestObj )
return Zend_Controller_Front::getInstance()
-&getDispatcher()
-&isDispatchable( $zfRequestObj );
My actionMethodExists() method is a little bit more complex. The dispatcher's interface is a bit misleading (getControllerClass() does not actually return a classname), so we have to jump through some hoops to get the actual controller class name, then load the class in time for the call to PHP's builtin method_exists() function:
class MyPlugin extends Zend_Controller_Plugin_Abstract
* @returns boolean - TRUE if action method exists
protected function actionMethodExists( Zend_Controller_Request_Abstract $zfRequestObj )
//getControllerClass() does not return the module prefix
$controllerClassSuffix = Zend_Controller_Front::getInstance()
-&getDispatcher()
-&getControllerClass( $zfRequestObj );
$controllerClassName = Zend_Controller_Front::getInstance()
-&getDispatcher()
-&formatClassName( $zfRequestObj-&getModuleName() , $controllerClassSuffix );
//load the class before we call method_exists()
Zend_Controller_Front::getInstance()
-&getDispatcher()
-&loadClass( $controllerClassSuffix );
$actionMethod = Zend_Controller_Front::getInstance()
-&getDispatcher()
-&getActionMethod( $zfRequestObj );
return ( method_exists( $controllerClassName, $actionMethod ) );
2,40933052
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .25897
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 血脉喷张有这个词吗 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信