From: Laury GvR Date: Fri, 25 Jul 2014 14:36:31 +0000 (-0400) Subject: File added to enable site user area X-Git-Tag: VV1^2~71 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c3ae64558ca6e7b59cf68e5dfbee0308195cb29c;p=web%2FCityofMI.git File added to enable site user area Registry.php added to enable a user area for the website, not just the admin side. Source: cheboygancounty --- diff --git a/Registry.php b/Registry.php new file mode 100644 index 0000000..d47a9c7 --- /dev/null +++ b/Registry.php @@ -0,0 +1,106 @@ + + * @copyright 2012 Gaslight Media + * @license Gaslight Media + * @version SVN: $Id$ + * @link <> + */ + +/** + * Registry + * + * Registry.php class to hold objects for access anywhere + * + * PHP version 5.2 + * + * @category CommonApps + * @package Registry + * @author Steve Sutton + * @copyright 2012 Gaslight Media + * @license Gaslight Media + * @version Release: 1.0 + * @link <> + */ + +class Registry +{ + static private $_store = array(); + + /** + * Add a object to the Registry::_store + * + * @param type $object Object + * @param type $name name of object key + * + * @return type + */ + static public function add($object, $name = null) + { + // Use the class name if no name given, simulates singleton + $name = (!is_null($name)) ?$name: get_class($object); + + $return = null; + if (isset(self::$_store[$name])) { + // Store the old object for returning + $return = self::$_store[$name]; + } + + self::$_store[$name] = $object; + return $return; + } + + /** + * get the object from the Registry::_store + * + * @param type $name Name of the object key + * + * @return type + * @throws Exception + */ + static public function get($name) + { + if (!self::contains($name)) { + throw new Exception("Object does not exist in registry"); + } + + return self::$_store[$name]; + } + + /** + * Check to see if the Registry::_store contains the object + * + * @param type $name name of object key + * + * @return boolean + */ + static public function contains($name) + { + if (!isset(self::$_store[$name])) { + return false; + } + + return true; + } + + /** + * Remove the object from the Registry::_store + * + * @param type $name name of object key + * + * @return void + */ + static public function remove($name) + { + if (self::contains($name)) { + unset(self::$_store[$name]); + } + } +}