<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */


class SettingsFactory
{
  
  private static $instances = array();

  
  public static function getSettings($classname)
  {
    if (!isset(self::$instances[$classname])) {
      if (class_exists($classname)) {
        $uri = SettingsClass::getPath() . $classname . '.php';
        if (file_exists($uri)) {
          self::$instances[$classname] = call_user_func(array($classname, 'load'), $classname);
          if (self::$instances[$classname] !== false) {
            self::$instances[$classname]->extendSettingsWithNewDefaults();
          }
        } else {
          self::$instances[$classname] = new $classname();
        }
      } else {
        throw new Exception('ungültige Konfigdatei: ' . $classname);
      }
    }

    return self::$instances[$classname];
  }
}