/** * Returns a reference to a Format object, only creating it * if it doesn't already exist. * * @param string The format to load * @return object Registry format handler * @throws RokCommon_Loader_Exception * @since 1.5 */ public static function getInstance($type) { // Initialize static variable. if (!isset(self::$instances)) { self::$instances = array(); } // Sanitize format type. $type = strtoupper(preg_replace('/[^A-Z0-9_]/i', '', $type)); // Only instantiate the object if it doesn't already exist. if (!isset(self::$instances[$type])) { // Only load the file the class does not exist. $class = 'RokCommon_Registry_Format_' . $type; if (!class_exists($class)) { throw new RokCommon_Loader_Exception('Unable to find Registry format ' . $type); } self::$instances[$type] = new $class(); } return self::$instances[$type]; }