Joomla如何判断一个扩展是否已经安装

在开发中,有时候我们需要做一些依赖关系的判断,比如在做ZMAXSHOP的开发的时候,我们需要判断系统是否已经安装了积分组件。
 
要实现这个要求,需要使用JComponentHelper类。该类提供了一个isInstallerd方法。具体的实现代码如下:
/**
77 * Checks if a component is installed
78 *
79 * @param string $option The component option.
80 *
81 * @return integer
82 *
83 * @since 3.4
84 */
85 public static function isInstalled($option)
86 {
87 $db = JFactory::getDbo();
88
89 return (int) $db->setQuery(
90 $db->getQuery(true)
91 ->select('COUNT(' . $db->quoteName('extension_id') . ')')
92 ->from($db->quoteName('#__extensions'))
93 ->where($db->quoteName('element') . ' = ' . $db->quote($option))
94 ->where($db->quoteName('type') . ' = ' . $db->quote('component'))
95 )->loadResult();
96 }
已邀请:

admin - Joomla发烧友,灌篮高手粉丝

赞同来自:

关于JComponetHelper类的更多信息请参考:http://www.joomlachina.cn/joomla/api/source-class-JComponentHelper.html#62-74

要回复问题请先登录注册