Check for CLI or system/updates route and disable any plugin initialization

This commit is contained in:
Sam Georges 2014-10-09 17:46:23 +11:00
parent 7e62ef5925
commit d78dadafd0
2 changed files with 16 additions and 2 deletions

View File

@ -60,6 +60,15 @@ class ServiceProvider extends ModuleServiceProvider
App::singleton('backend.menu', function() { return \Backend\Classes\NavigationManager::instance(); }); App::singleton('backend.menu', function() { return \Backend\Classes\NavigationManager::instance(); });
App::singleton('backend.auth', function() { return \Backend\Classes\AuthManager::instance(); }); App::singleton('backend.auth', function() { return \Backend\Classes\AuthManager::instance(); });
/*
* Check for CLI or system/updates route and disable any plugin initialization
* @todo This should be moved to middleware
*/
$requestPath = \October\Rain\Router\Helper::normalizeUrl(\Request::path());
$systemPath = \October\Rain\Router\Helper::normalizeUrl(Config::get('cms.backendUri') . '/system/updates');
if (App::runningInConsole() || stripos($requestPath, $systemPath) === 0)
PluginManager::$noInit = true;
/* /*
* Register all plugins * Register all plugins
*/ */

View File

@ -56,6 +56,11 @@ class PluginManager
*/ */
protected $disabledPlugins = []; protected $disabledPlugins = [];
/**
* @var boolean Prevent all plugins from registering or booting
*/
public static $noInit = false;
/** /**
* Initializes the plugin manager * Initializes the plugin manager
*/ */
@ -111,7 +116,7 @@ class PluginManager
*/ */
public function registerAll() public function registerAll()
{ {
if ($this->registered) if ($this->registered || self::$noInit)
return; return;
foreach ($this->plugins as $pluginId => $plugin) { foreach ($this->plugins as $pluginId => $plugin) {
@ -166,7 +171,7 @@ class PluginManager
*/ */
public function bootAll() public function bootAll()
{ {
if ($this->booted) if ($this->booted || self::$noInit)
return; return;
foreach ($this->plugins as $plugin) { foreach ($this->plugins as $plugin) {