diff options
author | Andrew Dolgov <[email protected]> | 2013-04-18 12:27:34 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-04-18 12:27:34 +0400 |
commit | 1ffe3391f902c4baa984982f19e61a0e45de21ff (patch) | |
tree | 4b0b7554c42a6df823db9cf90b925151c796f696 /classes/pluginhost.php | |
parent | 52d88392dad52ec4d5607fef7479d74dee8b8be4 (diff) |
make pluginhost a singleton
Diffstat (limited to 'classes/pluginhost.php')
-rw-r--r-- | classes/pluginhost.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/classes/pluginhost.php b/classes/pluginhost.php index c10f789b5..1c490b1ef 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -10,6 +10,7 @@ class PluginHost { private $api_methods = array(); private $owner_uid; private $debug; + private static $instance; const HOOK_ARTICLE_BUTTON = 1; const HOOK_ARTICLE_FILTER = 2; @@ -35,13 +36,24 @@ class PluginHost { const KIND_SYSTEM = 2; const KIND_USER = 3; - function __construct($dbh) { - $this->dbh = $dbh; + function __construct($ignored = false) { + $this->dbh = Db::get(); $this->storage = $_SESSION["plugin_storage"]; if (!$this->storage) $this->storage = array(); } + private function __clone() { + // + } + + public static function getInstance() { + if (self::$instance == null) + self::$instance = new self(); + + return self::$instance; + } + private function register_plugin($name, $plugin) { //array_push($this->plugins, $plugin); $this->plugins[$name] = $plugin; |