Jeff PHP framework  0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
singleton.class.php
Go to the documentation of this file.
00001 <?php
00023 abstract class singleton {
00024         
00025         /*
00026          * @brief array containing the singleton instances
00027          */
00028         protected static $_instances = array();
00029         
00038         protected function __construct() {
00039 
00040         }
00041 
00049         public static function instance() {
00050         
00051                 $class = get_called_class();
00052                 if(array_key_exists($class, self::$_instances) === false) {
00053                         self::$_instances[$class] = new static();
00054                 }
00055                 
00056                 return self::$_instances[$class];
00057 
00058         }
00059 
00067         public function __clone() {
00068                 Error::syserrorMessage('singleton', '__clone', __("CannotCloneSingleton"), __LINE__);
00069         }
00070         
00078         public function __sleep() {
00079                 Error::syserrorMessage('singleton', '__sleep', __("CannotSerializeSingleton").get_called_class(), __LINE__);
00080         }
00081         
00089         public function __wakeup() {
00090                 Error::syserrorMessage('singleton', '__wakeup', __("CannotSerializeSingleton"), __LINE__);
00091         }
00092 
00093 }
00094 
00095 ?>