40 lines
879 B
PHP
40 lines
879 B
PHP
|
<?php
|
||
|
/*****************************************************************************
|
||
|
* Registry.php
|
||
|
* Allows sharing static variables between classes.
|
||
|
*
|
||
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
||
|
*****************************************************************************/
|
||
|
|
||
|
class Registry
|
||
|
{
|
||
|
public static $storage = [];
|
||
|
|
||
|
public static function set($key, $value)
|
||
|
{
|
||
|
self::$storage[$key] = $value;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static function has($key)
|
||
|
{
|
||
|
return isset(self::$storage[$key]);
|
||
|
}
|
||
|
|
||
|
public static function get($key)
|
||
|
{
|
||
|
if (!isset(self::$storage[$key]))
|
||
|
trigger_error('Key does not exist in Registry: ' . $key, E_USER_ERROR);
|
||
|
|
||
|
return self::$storage[$key];
|
||
|
}
|
||
|
|
||
|
public static function remove($key)
|
||
|
{
|
||
|
if (!isset(self::$storage[$key]))
|
||
|
trigger_error('Key does not exist in Registry: ' . $key, E_USER_ERROR);
|
||
|
|
||
|
unset(self::$storage[$key]);
|
||
|
}
|
||
|
}
|