$propetyFile Name der Propertydatei */ public static function singleton($propetyFile = self::PROPERTIES_DEFAULT_PATH){ if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c; } return self::$instance; } /** * include_once auf ein Propertiy * @param $className Name des Property * @param $propetyFile Name der Propertydatei */ public static function import($className, $propetyFile = self::PROPERTIES_DEFAULT_PATH){ try { self::singleton($propetyFile)->includeByKey($className); } catch (Exception $e){ echo ($e); } } /** * @var Array array of included filepaths * @access private */ private $cach = array(); /** * @access public */ public function __construct($propetyFile = self::PROPERTIES_DEFAULT_PATH){ parent::__construct($propetyFile); } /** * @access public * @param String key * @retrun Boolean * @throw Exception */ public function includeByKey($key){ $path = $this->$key; $retVal = false; /** check if the file is allreadx included */ if (in_array($path, $this->cach)){ /** check if the file exist */ } elseif (file_exists($path)){ /** include the file */ include_once($path); /** add the path to the cach */ $this->cach[] = $path; $retVal = true; /** else create error */ } else { throw new Exception(__METHOD__." cant include the file {$key} => {$path}"); } return $retVal; } } ?>