简体   繁体   English

Joomla得到('项目')以及它是如何工作的

[英]Joomla get('Items') and how it works

I am looking at line 34 of /administrator/components/com_contact/views/contacts/view.html.php where is says $this->items = $this->get('Items'); 我正在查看/administrator/components/com_contact/views/contacts/view.html.php的第34行,其中显示$this->items = $this->get('Items'); What I don't understand is how that is actually calling the protected function getListQuery() on line 123 of /administrator/components/com_contact/models/contacts.php 我不明白的是,实际上是如何在/administrator/components/com_contact/models/contacts.php的第123行调用protected function getListQuery()

There are also some other things I don't understand how are working... like 还有其他一些我不明白的工作方式......就像

$this->pagination   = $this->get('Pagination');
$this->state        = $this->get('State');

What are these calling? 这些叫什么? I looked at the documentation for "get()" but it doesn't say what these are actually calling because I don't see any methods called getPagination, getState or getItems... It appears the get('Items') is somehow magically calling getListQuery(). 我看了一下“get()”的文档,但它没有说明这些实际调用的内容,因为我没有看到任何名为getPagination,getState或getItems的方法......看来get('Items')是某种方式神奇地调用getListQuery()。

I'm presuming 1.7/2.5+ here... 我假设这里有1.7 / 2.5 + ......

In Joomla!'s MVC the view contacts ( ContactViewContacts which extends JView ) automatically loads the model contacts (or in J! terminology ContactModelContacts ) which as a class extends JModelList . 在Joomla!的MVC中,视图contactsContactViewContacts extends JView )自动加载模型contacts (或J!术语ContactModelContacts ),它作为类extends JModelList

The get() looks in the view to get data from a registered model or a property of the view. get()在视图中查找以从注册的模型或视图的属性获取数据。

So; 所以;

$this->items = $this->get('Items');

is actually a call to the model ContactModelContacts which has a matching getItems() in it's parent . 实际上是对模型ContactModelContacts的调用,它在parent具有匹配的getItems()

The model file com_contact/models/contacts.php doesn't implement it's own getItems() , so the getItems() from the JModelList class is used (found in /libraries/joomla/application/component/modellist.php ). 模型文件com_contact/models/contacts.php没有实现它自己的getItems() ,因此使用了来自JModelList类的getItems() (可在/libraries/joomla/application/component/modellist.php找到)。

This in turn calls getListQuery() - no magic just inheritance. 这反过来调用getListQuery() - 没有魔法只是继承。

The $this->get('Pagination') is doing the same thing, ie. $this->get('Pagination')正在做同样的事情,即。 accessing the implementation in the models parent. 访问模型父级中的实现。

The $this->get('State') is probably going all the way back to the JModel implementation. $this->get('State')可能会一直回到JModel实现。

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

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