SimpleExtension priority framework
This commit is contained in:
parent
23cc49592d
commit
d80ccbe497
2 changed files with 7 additions and 3 deletions
|
@ -74,8 +74,10 @@ interface Extension {
|
|||
*
|
||||
* Also loads the theme object into $this->theme if available
|
||||
*
|
||||
* index.php will load all SimpleExtension subclasses with default
|
||||
* priority, so no need for register_extension(new Foo())
|
||||
* index.php will load all SimpleExtension subclasses,
|
||||
* so no need for register_extension(new Foo())
|
||||
*
|
||||
* Automatic registration is done with priority returned by get_priority()
|
||||
*
|
||||
* Hopefully this removes as much copy & paste code from the extension
|
||||
* files as possible~
|
||||
|
@ -101,6 +103,8 @@ abstract class SimpleExtension implements Extension {
|
|||
$this->_child->$name($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_priority() {return 50;}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,7 +117,7 @@ try {
|
|||
if(is_subclass_of($class, "SimpleExtension")) {
|
||||
$c = new $class();
|
||||
$c->i_am($c);
|
||||
add_event_listener($c);
|
||||
add_event_listener($c, $c->get_priority());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue