Improve plugin load speed.

pull/2487/head
jmontoyaa 7 years ago
parent f19255ee5e
commit 96fd16d8f9
  1. 2
      main/admin/settings.lib.php
  2. 12
      main/inc/lib/plugin.lib.php
  3. 12
      main/inc/lib/template.lib.php

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
use Symfony\Component\Filesystem\Filesystem;
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\SystemTemplate;
@ -127,6 +128,7 @@ function handleExtensions()
*/
function handlePlugins()
{
Session::erase('plugin_data');
$plugin_obj = new AppPlugin();
$token = Security::get_token();
if (isset($_POST['submit_plugins'])) {

@ -1,6 +1,8 @@
<?php
/* See license terms in /license.txt */
use ChamiloSession as Session;
/**
* Class AppPlugin
*/
@ -408,10 +410,10 @@ class AppPlugin
*/
public function getPluginInfo($plugin_name, $forced = false)
{
static $plugin_data = array();
$pluginData = Session::read('plugin_data');
if (isset($plugin_data[$plugin_name]) && $forced == false) {
return $plugin_data[$plugin_name];
if (isset($pluginData[$plugin_name]) && $forced == false) {
return $pluginData[$plugin_name];
} else {
$plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php";
@ -443,8 +445,8 @@ class AppPlugin
$settings_filtered[$item['variable']] = $item['selected_value'];
}
$plugin_info['settings'] = $settings_filtered;
$plugin_data[$plugin_name] = $plugin_info;
$pluginData[$plugin_name] = $plugin_info;
Session::write('plugin_data', $pluginData);
return $plugin_info;
}
}

@ -216,7 +216,7 @@ class Template
//1. Showing installed plugins in regions
$pluginRegions = $this->plugin->get_plugin_regions();
foreach ($pluginRegions as $region) {
$this->set_plugin_region($region);
$this->setPluginRegion($region);
}
//2. Loading the course plugin info
@ -1247,7 +1247,7 @@ class Template
* @param string $pluginRegion
* @return null
*/
public function set_plugin_region($pluginRegion)
public function setPluginRegion($pluginRegion)
{
if (!empty($pluginRegion)) {
$regionContent = $this->plugin->load_region(
@ -1261,10 +1261,14 @@ class Template
// The plugin_info variable is available inside the plugin index
$pluginInfo = $this->plugin->getPluginInfo($plugin_name);
if (isset($pluginInfo['is_course_plugin']) && $pluginInfo['is_course_plugin']) {
if (isset($pluginInfo['is_course_plugin']) &&
$pluginInfo['is_course_plugin']
) {
$courseInfo = api_get_course_info();
if (!empty($courseInfo)) {
if (isset($pluginInfo['obj']) && $pluginInfo['obj'] instanceof Plugin) {
if (isset($pluginInfo['obj']) &&
$pluginInfo['obj'] instanceof Plugin
) {
/** @var Plugin $plugin */
$plugin = $pluginInfo['obj'];
$regionContent .= $plugin->renderRegion($pluginRegion);

Loading…
Cancel
Save