Improve PluginManager code (#5023)

This commit is contained in:
Marc Jauvin 2020-04-02 11:30:15 -04:00 committed by GitHub
parent 600fbd7cfa
commit b1d41caf03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 11 deletions

View File

@ -208,21 +208,17 @@ class PluginManager
*/
public function registerPlugin($plugin, $pluginId = null)
{
if (!$pluginId) {
$pluginId = $this->getIdentifier($plugin);
}
if (!$plugin) {
return;
}
/**
* Verify that the provided plugin should be registered
*/
if ($plugin->disabled || (self::$noInit && !$plugin->elevated)) {
if (!$plugin || $plugin->disabled || (self::$noInit && !$plugin->elevated)) {
return;
}
if (!$pluginId) {
$pluginId = $this->getIdentifier($plugin);
}
$pluginPath = $this->getPluginPath($plugin);
$pluginNamespace = strtolower($pluginId);
@ -609,7 +605,7 @@ class PluginManager
{
$code = $this->getIdentifier($id);
$code = $this->normalizeIdentifier($code);
if (array_key_exists($code, $this->disabledPlugins)) {
if (isset($this->disabledPlugins[$code])) {
return false;
}
@ -634,7 +630,7 @@ class PluginManager
{
$code = $this->getIdentifier($id);
$code = $this->normalizeIdentifier($code);
if (!array_key_exists($code, $this->disabledPlugins)) {
if (!isset($this->disabledPlugins[$code])) {
return false;
}