Plugin autoloader
This commit is contained in:
parent
989d75886f
commit
869193fa18
|
@ -8,10 +8,18 @@
|
||||||
class AdminerPlugin extends Adminer {
|
class AdminerPlugin extends Adminer {
|
||||||
var $plugins;
|
var $plugins;
|
||||||
|
|
||||||
/**
|
/** Register plugins
|
||||||
* @param array
|
* @param array object instances or null to register all classes starting by 'Adminer'
|
||||||
*/
|
*/
|
||||||
function AdminerPlugin($plugins) {
|
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;
|
$this->plugins = $plugins;
|
||||||
// it is possible to use ReflectionObject in PHP 5 to find out which plugins defines which methods at once
|
// it is possible to use ReflectionObject in PHP 5 to find out which plugins defines which methods at once
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue