Skip to content

Instantly share code, notes, and snippets.

@webkader
Last active August 29, 2015 14:24
Show Gist options
  • Save webkader/aaac95a8ecca791b3a1e to your computer and use it in GitHub Desktop.
Save webkader/aaac95a8ecca791b3a1e to your computer and use it in GitHub Desktop.
Magic Registry Class
// Um aus verschiedenen Klassen auf "globale" Objekte und Variablen zuzugreifen, gibt es das Registry.
// Die Registry kann als abstract deklariert werden, da nur statische Attribute und Methoden verwendet werden.
abstract class Registry
{
static $objects = array();
/**
* Registry::get()
*
* @param mixed $name
* @return
*/
public static function get($name)
{
return isset(self::$objects[$name]) ? self::$objects[$name] : null;
}
/**
* Registry::set()
*
* @param mixed $name
* @param mixed $object
*/
public static function set($name, $object)
{
self::$objects[$name] = $object;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment