/**
* Loads the published plugins.
*
* @return array An array of published plugins
*
* @since 3.2
*/
protected static function load()
{
if (static::$plugins !== null) {
return static::$plugins;
}
$levels = Factory::getUser()->getAuthorisedViewLevels();
/** @var \Joomla\CMS\Cache\Controller\CallbackController $cache */
$cache = Factory::getCache('com_plugins', 'callback');
$loader = function () use($levels) {
$db = Factory::getDbo();
$query = $db->getQuery(true)->select($db->quoteName(['folder', 'element', 'params', 'extension_id'], ['type', 'name', 'params', 'id']))->from($db->quoteName('#__extensions'))->where([$db->quoteName('enabled') . ' = 1', $db->quoteName('type') . ' = ' . $db->quote('plugin'), $db->quoteName('state') . ' IN (0,1)'])->whereIn($db->quoteName('access'), $levels)->order($db->quoteName('ordering'));
$db->setQuery($query);
return $db->loadObjectList();
};
try {
static::$plugins = $cache->get($loader, [], md5(implode(',', $levels)), false);
} catch (CacheExceptionInterface $cacheException) {
static::$plugins = $loader();
}
return static::$plugins;
}