Elgg\Database\Plugins::load PHP Method

load() public method

Loads all active plugins in the order specified in the tool admin panel.
public load ( ) : boolean
return boolean
    function load()
    {
        if ($this->timer) {
            $this->timer->begin([__METHOD__]);
        }
        $plugins_path = elgg_get_plugins_path();
        $start_flags = ELGG_PLUGIN_INCLUDE_START | ELGG_PLUGIN_REGISTER_VIEWS | ELGG_PLUGIN_REGISTER_ACTIONS | ELGG_PLUGIN_REGISTER_LANGUAGES | ELGG_PLUGIN_REGISTER_WIDGETS | ELGG_PLUGIN_REGISTER_CLASSES;
        if (!$plugins_path) {
            return false;
        }
        // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
        if (file_exists("{$plugins_path}/disabled")) {
            if (elgg_is_admin_logged_in() && elgg_in_context('admin')) {
                system_message(_elgg_services()->translator->translate('plugins:disabled'));
            }
            return false;
        }
        if (elgg_get_config('system_cache_loaded')) {
            $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_VIEWS;
        }
        if (!empty($GLOBALS['_ELGG']->i18n_loaded_from_cache)) {
            $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_LANGUAGES;
        }
        $plugins = $this->boot_plugins;
        if (!$plugins) {
            $this->active_guids_known = true;
            return true;
        }
        $return = true;
        foreach ($plugins as $plugin) {
            $id = $plugin->getID();
            try {
                $plugin->start($start_flags);
                $this->active_guids[$id] = $plugin->guid;
            } catch (Exception $e) {
                $disable_plugins = elgg_get_config('auto_disable_plugins');
                if ($disable_plugins === null) {
                    $disable_plugins = true;
                }
                if ($disable_plugins) {
                    $plugin->deactivate();
                    $msg = _elgg_services()->translator->translate('PluginException:CannotStart', array($id, $plugin->guid, $e->getMessage()));
                    elgg_add_admin_notice("cannot_start {$id}", $msg);
                    $return = false;
                }
            }
        }
        $this->active_guids_known = true;
        if ($this->timer) {
            $this->timer->end([__METHOD__]);
        }
        return $return;
    }