[eluser]InsiteFX[/eluser]
Here is something that I have been playing with, still working on it but it does work!
You can also store array's if you serialize and unserialize them.
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Class Registry
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author Raymond King aka:(InsiteFX).
* @copyright Copyright (c) 2005 - 2011, Advanced Computer Systems, LLC.
* @license http://www.learnellislab.com/codeigniter/user-guide/license.html
* @link http://www.learnellislab.com/codeigniter/user-guide/libraries/name.html
* @since Version 1.0.0
*/
// Autoload this library in application/config/autoload.php
class Registry {
/**
* Class Variables - protected, private, public and static variables.
* --------------------------------------------------------------------
*/
private static $registry = array();
// --------------------------------------------------------------------
/**
* __construct()
*
* Class Constuctor PHP 5+
*
* @access public
* @param array
* @return void
*/
public function __construct($config = array())
{
// NOTE: if you use a config file it must be named the same as this Class!
// application/config/registry.php
foreach ($config as $key => $value)
{
if ( ! self::exists($key))
{
self::$registry[$key] = $value;
}
}
}
// --------------------------------------------------------------------
/**
* add() - Example: $this->registry->add($key, $value);
*
* Adds an item to the registry array
*
* @access public
* @param string - item's unique key
* @param mixed - value
* @return boolean
*/
public function add($key, $value)
{
if ( ! self::exists($key))
{
self::$registry[$key] = $value;
return TRUE;
}
else
{
return FALSE;
}
}
// --------------------------------------------------------------------
/**
* exists() - Example: $result = $this->registry->exists($key);
*
* Returns TRUE if item is registered in the registry array
*
* @access public
* @param string - key name
* @return boolean
*/
public function exists($key)
{
if (is_string($key))
{
return array_key_exists($key, self::$registry);
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* get() - Example: $this->registry->get($key);
*
* Returns the registered key value
*
* @access public
* @param string - key name
* @return mixed - (FALSE if key name is not in registry array)
*/
public function get($key)
{
if (self::exists($key))
{
return self::$registry[$key];
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* delete() - Example: $result = $this->registry->delete($key);
*
* delete's a registry entry
*
* @access public
* @param string - key name
* @return boolean
*/
public function delete($key)
{
if (self::exists($key))
{
unset(self::$registry[$key]);
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* clear() - Example: $this->registry->clear();
*
* Clears the entire registry array
*
* @access public
* @return boolean
*/
public function clear()
{
self::$registry = array();
}
// --------------------------------------------------------------------
/**
* debug() - Example: echo var_dump($this->registry->debug());
*
* Return's the entire registry array for debugging
* @access public
* @return array
*/
public function debug()
{
return self::$registry;
}
}
// ------------------------------------------------------------------------
/* End of file Registry.php */
/* Location: ./application/libraries/Registry.php */
InsiteFX