From f951167013dc01a7162a93c91c1f1f6b3d4034d8 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 16 Oct 2005 19:57:43 +0000 Subject: [PATCH] Added getobject() system --- kernel.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kernel.php b/kernel.php index 455902e..21f8e81 100644 --- a/kernel.php +++ b/kernel.php @@ -220,6 +220,8 @@ class Shared_Object_Framework * @param string Name of the framework file to load * @param string Internal variable to initialize as; to not instantiate (just require) leave it as NULL * @param bool Globalize the internal variable? + * + * @return object Instantiated instance */ function &load($framework, $asobject, $globalize = false) { @@ -247,6 +249,8 @@ class Shared_Object_Framework return; } + $this->modules["$framework"] = $asobject; + if (isset($this->$asobject)) { trigger_error('Cannot instantiate framework `' . $framework . '` into `' . $asobject . '`', E_USER_ERROR); @@ -262,6 +266,23 @@ class Shared_Object_Framework return $this->$asobject; } + /** + * Returns the instance of a loaded module + * + * @param string Framework name + * + * @return object Instantiated instance + */ + function &getobject($framework) + { + if (!$this->is_loaded($framework)) + { + trigger_error('Framework module `' . $framework . '` is not loaded', E_USER_WARNING); + } + + return $this->{$this->modules["$framework"]}; + } + /** * Prints a list of all currently loaded framework modules * -- 2.22.5