From a687059f7a4d65e1a5e7dcd7e4e8ef3f2ce478ff Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 16 Aug 2006 03:21:59 +0000 Subject: [PATCH] Added initial BSRegister class --- Register.php | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+) create mode 100644 Register.php diff --git a/Register.php b/Register.php new file mode 100644 index 0000000..653eb98 --- /dev/null +++ b/Register.php @@ -0,0 +1,264 @@ +application = $name; + } + + // ################################################################### + /** + * Gets the application name + * + * @return string Application name + */ + public function getApplication() + { + return $this->application; + } + + // ################################################################### + /** + * Sets the application's working path + * + * @param string Path + */ + public function setAppPath($path) + { + $this->appPath = BSFunctions::FetchSourcePath($path); + } + + // ################################################################### + /** + * Returns the path to the application + * + * @return string Application path + */ + public function getAppPath() + { + return $this->appPath; + } + + // ################################################################### + /** + * Sets the application version + * + * @param string Application version + */ + public function setAppVersion($vers) + { + $this->appVersion = $vers; + } + + // ################################################################### + /** + * Gets the application version + * + * @return string Application version + */ + public function getAppVersion() + { + return $this->appVersion; + } + + // ################################################################### + /** + * Sets the application's web path, which is the full path from the + * server's web root + * + * @param string Path + */ + public function setWebPath($path) + { + $this->webPath = BSFunctions::FetchSourcePath($path); + } + + // ################################################################### + /** + * Returns the web path to the application + * + * @return string Application's web path + */ + public function getWebPath() + { + return $this->webPath; + } + + // ################################################################### + /** + * Sets the debug state + * + * @param bool Debug mode on? + */ + public function setDebug($debug) + { + $this->debug = $debug; + } + + // ################################################################### + /** + * Gets the debug mode state + * + * @return bool Debug mode on? + */ + public function getDebug() + { + return $this->debug; + } + + // ################################################################### + /** + * Registers a value in the master registry. You cannot overwrite + * values. You must first unregister() them if you wish to do so. + * + * @param string Registry key + * @param mixed Value to register + */ + public function register($key, $value) + { + if (isset($this->registry["$key"])) + { + throw new Exception('Cannot overwrite a key in the registry'); + } + + $this->registry["$key"] = $value; + } + + // ################################################################### + /** + * Unregisters a value from the registry. This removes all traces of + * it from this object. + * + * @param string Registry key + */ + public function unregister($key) + { + if (!isset($this->registry["$key"])) + { + throw new Exception('You cannot unregister a key that does not exist'); + } + + unset($this->registry["$key"]); + } + + // ################################################################### + /** + * This gets a value from the registry with a specific key + * + * @param string The key + * + * @return mixed Value in the registry for key + */ + public function get($key) + { + if (!isset($this->registry["$key"])) + { + throw new Exception('Cannot access the registry with a non-existent key'); + } + + return $this->registry["$key"]; + } + + // ################################################################### + /** + * Returns the entire registry stack + * + * @return array Complete registry + */ + public function getAll() + { + return $this->registry; + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.43.5