简体   繁体   English

什么时候是Zend_Controller_Request_Http以外的控制器

[英]When is controller other than Zend_Controller_Request_Http

I keep seeing this line of code in many plugins. 我在许多插件中一直看到这一行代码。 What exactly does it do, and what other possibilities are there other than Request_Http 它到底是做什么的,除了Request_Http之外还有其他可能性吗

if (!$request instanceof Zend_Controller_Request_Http)
    return;

Sifting through the Zend Framework docs, I see that a sibling class of Zend_Controller_Request_Http is Zend_Controller_Request_Simple , which is used to get information about command-line requests to a ZF application. 仔细阅读Zend Framework文档,我看到Zend_Controller_Request_Http的同级类是Zend_Controller_Request_Simple ,该类用于获取有关对ZF应用程序的命令行请求的信息。 The plugins in question probably only work for web apps requested using a browser (or whatever HTTP client), so these plugins back out otherwise. 有问题的插件可能仅适用于使用浏览器(或任何HTTP客户端)请求的Web应用程序,因此这些插件会以其他方式退出。

即使每个类都不寻常,扩展Zend_Controller_Request_Abstract也会发生。

I believe that originally all of ZF's routing was based on the REQUEST_URI, so many of the routing classes operated on $request which was a string. 我相信最初ZF的所有路由都基于REQUEST_URI,因此许多路由类都在$ request上操作,后者是一个字符串。 In order to facilitate things such as routing for subdomains this was changed so that the whole request object was passed in. So checks such as the one in your example are merely checking that $request is a request object (and not a string) before calling its methods. 为了简化诸如子域路由之类的操作,对此进行了更改,以便传递整个请求对象。因此,在您的示例中进行的检查只是在调用前检查$ request是请求对象(而不是字符串)。它的方法。

(Disclaimer: this is speculation based on my knowledge of ZF's routing classes, I may be wrong!) (免责声明:这是基于我对ZF路由类的了解而做出的推测,我可能错了!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM