Implement cache for Plugin Manager

This commit is contained in:
Fedor A. Fetisov 2016-12-28 19:51:11 +03:00
parent 547efb38e4
commit 15dbe153f5
3 changed files with 31 additions and 3 deletions

View File

@ -33,7 +33,9 @@ $cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
// Run plugins
if (get_maintenance_mode() === false) {
PluginManager::getInstance()->loadPlugins($configs['plugins']);
$plugin_manager = PluginManager::getInstance();
$plugin_manager->setCache($cache_factory->getCache());
$plugin_manager->loadPlugins($configs['plugins']);
}
// Do the job.

View File

@ -43,7 +43,9 @@ $cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
// Run plugins
if (get_maintenance_mode() === false) {
PluginManager::getInstance()->loadPlugins($configs['plugins']);
$plugin_manager = PluginManager::getInstance();
$plugin_manager->setCache($cache_factory->getCache());
$plugin_manager->loadPlugins($configs['plugins']);
}
// The main route loader which loads nothig but works as a cache proxy for other

View File

@ -19,15 +19,18 @@
namespace Mibew\Plugin;
use Mibew\Cache\CacheAwareInterface;
use Mibew\Plugin\Utils as PluginUtils;
use Mibew\Maintenance\Utils as MaintenanceUtils;
use Stash\Interfaces\PoolInterface;
/**
* Manage plugins.
*
* Implements singleton pattern.
*/
class PluginManager
class PluginManager implements
CacheAwareInterface
{
/**
* An instance of Plugin Manager class.
@ -35,6 +38,11 @@ class PluginManager
*/
protected static $instance = null;
/**
* @var PoolInterface|null
*/
protected $cache = null;
/**
* Contains all loaded plugins
*
@ -56,6 +64,22 @@ class PluginManager
return self::$instance;
}
/**
* {@inheritdoc}
*/
public function setCache(PoolInterface $cache)
{
$this->cache = $cache;
}
/**
* {@inheritdoc}
*/
public function getCache()
{
return $this->cache;
}
/**
* Returns plugin instance.
*