mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 08:06:59 +02:00
Plugin autoloader
This commit is contained in:
@@ -8,10 +8,18 @@
|
||||
class AdminerPlugin extends Adminer {
|
||||
var $plugins;
|
||||
|
||||
/**
|
||||
* @param array
|
||||
/** Register plugins
|
||||
* @param array object instances or null to register all classes starting by 'Adminer'
|
||||
*/
|
||||
function AdminerPlugin($plugins) {
|
||||
if (!isset($plugins)) {
|
||||
$plugins = array();
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if (preg_match('~^Adminer(?!Plugin|$)~i', $class) && $class != get_class($this)) { // can use interface since PHP 5
|
||||
$plugins[$class] = new $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->plugins = $plugins;
|
||||
// it is possible to use ReflectionObject in PHP 5 to find out which plugins defines which methods at once
|
||||
}
|
||||
|
Reference in New Issue
Block a user