Back to ComponentHelper class

Method load

protected static bool
load
()
Load the installed components into the components property.
Returns
  • bool True on success
Since
  • 3.2

Method load - Source code

/**
 * Load the installed components into the components property.
 *
 * @return  boolean  True on success
 *
 * @since   3.2
 */
protected static function load()
{
    $loader = function () {
        $db = Factory::getDbo();
        $query = $db->getQuery(true)->select($db->quoteName(['extension_id', 'element', 'params', 'enabled'], ['id', 'option', null, null]))->from($db->quoteName('#__extensions'))->where([$db->quoteName('type') . ' = ' . $db->quote('component'), $db->quoteName('state') . ' = 0', $db->quoteName('enabled') . ' = 1']);
        $components = [];
        $db->setQuery($query);
        foreach ($db->getIterator() as $component) {
            $components[$component->option] = new ComponentRecord((array) $component);
        }
        return $components;
    };
    /** @var CallbackController $cache */
    $cache = Factory::getContainer()->get(CacheControllerFactoryInterface::class)->createCacheController('callback', ['defaultgroup' => '_system']);
    try {
        static::$components = $cache->get($loader, array(), __METHOD__);
    } catch (CacheExceptionInterface $e) {
        static::$components = $loader();
    }
    return true;
}