@@ 91-101 (lines=11) @@ | ||
88 | * @throws \phpbu\App\Exception |
|
89 | * @return mixed |
|
90 | */ |
|
91 | protected function create($type, $alias) |
|
92 | { |
|
93 | self::checkType($type); |
|
94 | $alias = strtolower($alias); |
|
95 | ||
96 | if (!isset(self::$classMap[$type][$alias])) { |
|
97 | throw new Exception(sprintf('unknown %s: %s', $type, $alias)); |
|
98 | } |
|
99 | $class = self::$classMap[$type][$alias]; |
|
100 | return new $class(); |
|
101 | } |
|
102 | ||
103 | /** |
|
104 | * Adapter Factory. |
|
@@ 265-274 (lines=10) @@ | ||
262 | * @param boolean $force Overwrite already registered class |
|
263 | * @throws \phpbu\App\Exception |
|
264 | */ |
|
265 | public static function register($type, $alias, $fqcn, $force = false) |
|
266 | { |
|
267 | self::checkType($type); |
|
268 | $alias = strtolower($alias); |
|
269 | ||
270 | if (!$force && isset(self::$classMap[$type][$alias])) { |
|
271 | throw new Exception(sprintf('%s is already registered use force parameter to overwrite', $type)); |
|
272 | } |
|
273 | self::$classMap[$type][$alias] = $fqcn; |
|
274 | } |
|
275 | ||
276 | /** |
|
277 | * Throws an exception if type is invalid. |