Move list of plugin types to plugin controller constant

There is no need to have them in a global variable.
This commit is contained in:
Andreas Gohr 2019-04-21 19:31:27 +02:00
parent fdf261bd6b
commit 1935a89170
4 changed files with 9 additions and 7 deletions

View File

@ -10,10 +10,12 @@ namespace dokuwiki\Extension;
class PluginController
{
/** @var array the types of plugins DokuWiki supports */
const PLUGIN_TYPES = ['auth', 'admin', 'syntax', 'action', 'renderer', 'helper', 'remote', 'cli'];
protected $list_bytype = array();
protected $tmp_plugins = array();
protected $plugin_cascade = array('default' => array(), 'local' => array(), 'protected' => array());
protected $list_bytype = [];
protected $tmp_plugins = [];
protected $plugin_cascade = ['default' => [], 'local' => [], 'protected' => []];
protected $last_local_config_file = '';
/**

View File

@ -192,7 +192,6 @@ init_paths();
init_files();
// setup plugin controller class (can be overwritten in preload.php)
$plugin_types = array('auth', 'admin','syntax','action','renderer', 'helper','remote','cli');
global $plugin_controller_class, $plugin_controller;
if (empty($plugin_controller_class)) $plugin_controller_class = dokuwiki\Extension\PluginController::class;

View File

@ -5,6 +5,8 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
use dokuwiki\Extension\PluginController;
// setup class autoloader
spl_autoload_register('load_autoload');
@ -133,7 +135,7 @@ function load_autoload($name){
// Plugin loading
if(preg_match(
'/^(auth|helper|syntax|action|admin|renderer|remote|cli)_plugin_(' .
'/^(' . implode('|', PluginController::PLUGIN_TYPES) . ')_plugin_(' .
DOKU_PLUGIN_NAME_REGEX .
')(?:_([^_]+))?$/',
$name,

View File

@ -772,11 +772,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
if (is_readable($infopath)) {
$this->localInfo = confToHash($infopath);
} elseif (!$this->isTemplate() && $this->isEnabled()) {
global $plugin_types;
$path = $this->getInstallDir().'/';
$plugin = null;
foreach ($plugin_types as $type) {
foreach (PluginController::PLUGIN_TYPES as $type) {
if (file_exists($path.$type.'.php')) {
$plugin = plugin_load($type, $this->base);
if ($plugin) break;