let's stop being php5.2 compatible

This commit is contained in:
Shish 2016-06-19 23:23:34 +01:00
parent 6febdec7b5
commit cb73a0caa0
2 changed files with 16 additions and 23 deletions

View file

@ -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;
}
}

View file

@ -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";
}
}