1 <?php
3 /**
4 * GOsa Registry of static class instances that are accessible
5 * from all locations.
6 *
7 * Creates a new instance of the requested class if required.
8 */
9 class Registry {
11 static private $registry = array();
13 private function __construct(){}
15 /**
16 * Returns a static instance of $class
17 * Creates a new instance of $class if required.
18 * @param string $class
19 * @return obj $$class
20 */
21 static function getInstance($class){
22 if (!isset(Registry::$registry[$class])){
23 Registry::$registry[$class]= new $class;
24 }
25 return Registry::$registry[$class];
26 }
27 }
29 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
30 ?>