Enable PicoDeprecated if no plugins are loaded

This commit is contained in:
Daniel Rudolf 2015-11-04 19:44:20 +01:00
parent ccac8dd4d3
commit 2a43b21bae

View File

@ -69,6 +69,7 @@ class PicoDeprecated extends AbstractPicoPlugin
*/ */
public function onPluginsLoaded(&$plugins) public function onPluginsLoaded(&$plugins)
{ {
if (!empty($plugins)) {
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
if (!is_a($plugin, 'PicoPluginInterface')) { if (!is_a($plugin, 'PicoPluginInterface')) {
// the plugin doesn't implement PicoPluginInterface; it uses deprecated events // the plugin doesn't implement PicoPluginInterface; it uses deprecated events
@ -79,6 +80,14 @@ class PicoDeprecated extends AbstractPicoPlugin
break; break;
} }
} }
} else {
// no plugins were found, so it actually isn't necessary to call deprecated events
// anyway, this plugin also ensures compatibility apart from events used by old plugins,
// so enable PicoDeprecated if it hasn't be explicitly enabled/disabled yet
if (!$this->isStatusChanged()) {
$this->setEnabled(true, true, true);
}
}
if ($this->isEnabled()) { if ($this->isEnabled()) {
$this->triggerEvent('plugins_loaded'); $this->triggerEvent('plugins_loaded');