jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Core/] [Singleton.php] - Blame information for rev 2

 

Line No. Rev Author Line
12simandl<?php
2 
3namespace Phem\Core;
4 
5abstract class Singleton extends Object
6{
7 
8 protected static $instances;
9 
10 protected function __construct()
11 {
12 
13 }
14 
15 protected function __clone()
16 {
17 
18 }
19 
20 public function __wakeup()
21 {
22 throw new CoreException("Cannot unserialize singleton");
23 }
24 
25 public static function getInstance()
26 {
27 $cls = get_called_class(); // late-static-bound class name
28 
29 if (!isset(static::$instances))
30 {
31 static::$instances = new Collection();
32 }
33 
34 if (!(static::$instances->containsKey($cls)))
35 {
36 self::$instances->put($cls,new static);
37 }
38 return self::$instances->get($cls);
39 }
40 
41}

Powered by WebSVN 2.2.1