«

为 Joomla CMSObject -> stdClass 准备扩展

时间:2025-1-9 17:01     作者:emer     分类:


在 joomla 6 中,adminmodel 中的 getitem() 方法将返回 stdclass 而不是 cmsobject。 这意味着该类的所有已弃用的功能将不可用。 joomla 6 中的开发人员应该直接使用 item 对象的属性,而不是使用过时的 set() 和 get() 方法。

旧的 joomla 方式

$article = $app->bootcomponent('content')->getmvcfactory()->createmodel('article', 'administrator')->getitem(1);
echo $article->get('title');
登录后复制

joomla 6 中的情况如何

$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
echo $article->title;
登录后复制

相应的 pull request 已被 joomla 6 分支接受。

joomla hub 上的公关

joomla 社区资源

以上就是为 Joomla CMSObject -> stdClass 准备扩展的详细内容,