为 Joomla CMSObject -> stdClass 准备扩展(扩展.CMSObject.Joomla.stdClass.gt...)

wufei1232025-01-24PHP13

在 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 github 上的公关

joomla 社区资源
  • https://joomla.org/
  • mattermost 中的 joomla 社区聊天
  • webtolk joomla 扩展

以上就是为 Joomla CMSObject -> stdClass 准备扩展的详细内容,更多请关注知识资源分享宝库其它相关文章!

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。