1 | <?php |
||
8 | class AliasLoader |
||
9 | { |
||
10 | /** |
||
11 | * The array of class aliases. |
||
12 | * |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $aliases; |
||
16 | |||
17 | /** |
||
18 | * Indicates if a loader has been registered before. |
||
19 | * |
||
20 | * @var bool |
||
21 | */ |
||
22 | protected $registered = false; |
||
23 | |||
24 | /** |
||
25 | * The singleton instance of the alias loader. |
||
26 | * |
||
27 | * @var \Magister\Services\Foundation\AliasLoader |
||
28 | */ |
||
29 | protected static $instance; |
||
30 | |||
31 | /** |
||
32 | * Create a new alias loader instance. |
||
33 | * |
||
34 | * @param array $aliases |
||
35 | */ |
||
36 | private function __construct($aliases) |
||
40 | |||
41 | /** |
||
42 | * Create a singleton alias loader instance. |
||
43 | * |
||
44 | * @param array $aliases |
||
45 | * |
||
46 | * @return static |
||
47 | */ |
||
48 | public static function getInstance(array $aliases = []) |
||
60 | |||
61 | /** |
||
62 | * Register the loader on the auto-loader stack. |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function register() |
||
74 | |||
75 | /** |
||
76 | * Register the class alias auto-loader. |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | protected function registerAutoloader() |
||
84 | |||
85 | /** |
||
86 | * Load a class alias if it is registered. |
||
87 | * |
||
88 | * @param string $alias |
||
89 | * |
||
90 | * @return void |
||
91 | */ |
||
92 | public function load($alias) |
||
98 | |||
99 | /** |
||
100 | * Set the registered aliases. |
||
101 | * |
||
102 | * @param array $aliases |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | public function setAliases(array $aliases) |
||
110 | |||
111 | /** |
||
112 | * Get the registered aliases. |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | public function getAliases() |
||
120 | |||
121 | /** |
||
122 | * Indicates if the loader has been registered. |
||
123 | * |
||
124 | * @return bool |
||
125 | */ |
||
126 | public function isRegistered() |
||
130 | |||
131 | /** |
||
132 | * Set the "registered" state of the loader. |
||
133 | * |
||
134 | * @param bool $value |
||
135 | * |
||
136 | * @return void |
||
137 | */ |
||
138 | public function setRegistered($value) |
||
142 | |||
143 | /** |
||
144 | * Set the value of the singleton alias loader. |
||
145 | * |
||
146 | * @param \Magister\Services\Foundation\AliasLoader $loader |
||
147 | * |
||
148 | * @return void |
||
149 | */ |
||
150 | public static function setInstance($loader) |
||
154 | |||
155 | /** |
||
156 | * The clone method. |
||
157 | * |
||
158 | * @return void |
||
159 | */ |
||
160 | private function __clone() |
||
163 | } |
||
164 |