diff --git a/core/extension.class.php b/core/extension.class.php index 2267e63a..dcbd1010 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -85,18 +85,13 @@ abstract class Extension { /** @var array which DBs this ext supports (blank for 'all') */ protected $db_support = []; - /** this theme's Themelet object */ + /** @var Themelet this theme's Themelet object */ public $theme; - // in PHP5.3, late static bindings can take care of this; __CLASS__ - // used here will refer to the subclass - // http://php.net/manual/en/language.oop5.late-static-bindings.php - /** @private */ - public function i_am(Extension $child) { - if(is_null($this->theme)) $this->theme = $this->get_theme_object($child, false); + public function __construct() { + $this->theme = $this->get_theme_object(get_called_class()); } - public function is_live() { global $database; return ( @@ -108,21 +103,21 @@ abstract class Extension { /** * Find the theme object for a given extension. * - * @param Extension $class - * @param bool $fatal - * @return bool + * @param string $base + * @return Themelet */ - private function get_theme_object(Extension $class, $fatal=true) { - $base = get_class($class); - if(class_exists('Custom'.$base.'Theme')) { - $class = 'Custom'.$base.'Theme'; - return new $class(); + private function get_theme_object($base) { + $custom = 'Custom'.$base.'Theme'; + $normal = $base.'Theme'; + + if(class_exists($custom)) { + return new $custom(); } - elseif ($fatal || class_exists($base.'Theme')) { - $class = $base.'Theme'; - return new $class(); - } else { - return false; + elseif(class_exists($normal)) { + return new $normal(); + } + else { + return null; } } diff --git a/core/util.inc.php b/core/util.inc.php index 0cb81ede..c3d5a6c5 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1429,7 +1429,6 @@ function _set_event_listeners() { elseif(is_subclass_of($class, "Extension")) { /** @var Extension $extension */ $extension = new $class(); - $extension->i_am($extension); // skip extensions which don't support our current database if(!$extension->is_live()) continue; @@ -1460,7 +1459,6 @@ function _dump_event_listeners($event_listeners, $path) { if($rclass->isAbstract()) {} elseif(is_subclass_of($class, "Extension")) { $p .= "\$$class = new $class(); "; - $p .= "\${$class}->i_am(\$$class);\n"; } }