加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Zend Framework – 在oop原理中,方法’$this-> getReq

发布时间:2020-12-13 17:18:48 所属栏目:PHP教程 来源:网络整理
导读:下面的方法如何工作? $this-getRequest()-getPost(); Zend_Controller_Request_Abstract类中没有方法getPost(),但它如何工作?在OOP原则中,方法getPost()应该出现在Zend_Controller_Request_Abstract中. 如果没有直接实例,Zend如何在类Zend_Controller_Requ
下面的方法如何工作?

$this->getRequest()->getPost();

Zend_Controller_Request_Abstract类中没有方法getPost(),但它如何工作?在OOP原则中,方法getPost()应该出现在Zend_Controller_Request_Abstract中.

如果没有直接实例,Zend如何在类Zend_Controller_Request_Http中拉取getPost()?

谢谢.

解决方法

Zend将首先将您的所有请求发送到可在Zend / Controller / Front.php上获得的FrontController. FrontController会将Http请求注入控制器,这里是它发生的代码

/**
     * Instantiate default request object (HTTP version) if none provided
     */
    if (null !== $request) {
        $this->setRequest($request);
    } elseif ((null === $request) && (null === ($request = $this->getRequest()))) {
        require_once 'Zend/Controller/Request/Http.php';
        $request = new Zend_Controller_Request_Http();
        $this->setRequest($request);
    }

The purpose of frontcontroller is to initialize the request
environment
,route the incoming request,and then dispatch any
discovered actions; it aggregates any responses and returns them when
the process is complete.

有关FrontController here的更多信息

进一步回答您的问题

/**
 * Return the Request object
 *
 * @return Zend_Controller_Request_Abstract
 */
public function getRequest()
{
    return $this->_request;
}

这就是Zend / Controller / Action.php中的内容 – 这里的评论说Zend_Controller_Request_Abstract’是’a’返回类型.我突出显示’is-a’,因为它可以返回任何’是-a’Zend_Controller_Request_Abstract的类.更多关于是 – 检查这个wikipedia页面

“In knowledge representation,object-oriented programming and design,is-a or is_a or is a (subsumption) is a relationship where one class D is a subclass of another class B (and so B is a superclass of D).”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读