1 <?php
2 3 4 5 6 7 8 9 10
11
12
13 14 15 16 17
18 class NeevoLoader {
19
20
21
22 private $list = array(
23 'ineevocache' => '/NeevoCache.php',
24 'ineevodriver' => '/INeevoDriver.php',
25 'ineevoobservable' => '/INeevoObservable.php',
26 'ineevoobserver' => '/INeevoObserver.php',
27 'neevo' => '/Neevo.php',
28 'neevobasestmt' => '/NeevoBaseStmt.php',
29 'neevocachefile' => '/NeevoCache.php',
30 'neevocachememcache' => '/NeevoCache.php',
31 'neevocachememory' => '/NeevoCache.php',
32 'neevocachesession' => '/NeevoCache.php',
33 'neevoconnection' => '/NeevoConnection.php',
34 'neevodriverexception' => '/NeevoException.php',
35 'neevoexception' => '/NeevoException.php',
36 'neevoimplementationexception' => '/NeevoException.php',
37 'neevoliteral' => '/Neevo.php',
38 'neevoobservermap' => '/NeevoObserverMap.php',
39 'neevoparser' => '/NeevoParser.php',
40 'neevoresult' => '/NeevoResult.php',
41 'neevoresultiterator' => '/NeevoResultIterator.php',
42 'neevorow' => '/NeevoRow.php',
43 'neevostmt' => '/NeevoStmt.php',
44 );
45
46
47 private static $instance;
48
49
50 private function __construct(){}
51
52
53 54 55 56
57 public static function getInstance(){
58 if(self::$instance === null)
59 self::$instance = new self;
60 return self::$instance;
61 }
62
63
64 65 66 67
68 public function register(){
69 spl_autoload_register(array($this, 'tryLoad'));
70 }
71
72
73 74 75 76
77 public function unregister(){
78 spl_autoload_unregister(array($this, 'tryLoad'));
79 }
80
81
82 83 84 85 86
87 public function tryLoad($type){
88 $type = trim(strtolower($type), '\\');
89
90 if(isset($this->list[$type]))
91 return include_once dirname(__FILE__) . $this->list[$type];
92 return false;
93 }
94
95
96 }
97