From d80ccbe497d923497c7cb944fdf256ee7fde882f Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 27 May 2010 18:43:44 +0100 Subject: [PATCH] SimpleExtension priority framework --- core/extension.class.php | 8 ++++++-- index.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/extension.class.php b/core/extension.class.php index 42763fca..49f73b73 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -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;} } /** diff --git a/index.php b/index.php index 1caaf898..15a4e2c0 100644 --- a/index.php +++ b/index.php @@ -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()); } }