|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Cloud |
|
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
19 */ |
|
20 |
|
21 /** |
|
22 * Abstract factory for Zend_Cloud resources |
|
23 * |
|
24 * @category Zend |
|
25 * @package Zend_Cloud |
|
26 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
27 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
28 */ |
|
29 class Zend_Cloud_AbstractFactory |
|
30 { |
|
31 /** |
|
32 * Constructor |
|
33 * |
|
34 * @return void |
|
35 */ |
|
36 private function __construct() |
|
37 { |
|
38 // private ctor - should not be used |
|
39 } |
|
40 |
|
41 /** |
|
42 * Get an individual adapter instance |
|
43 * |
|
44 * @param string $adapterOption |
|
45 * @param array|Zend_Config $options |
|
46 * @return null|Zend_Cloud_DocumentService_Adapter|Zend_Cloud_QueueService_Adapter|Zend_Cloud_StorageService_Adapter |
|
47 */ |
|
48 protected static function _getAdapter($adapterOption, $options) |
|
49 { |
|
50 if ($options instanceof Zend_Config) { |
|
51 $options = $options->toArray(); |
|
52 } |
|
53 |
|
54 if (!isset($options[$adapterOption])) { |
|
55 return null; |
|
56 } |
|
57 |
|
58 $classname = $options[$adapterOption]; |
|
59 unset($options[$adapterOption]); |
|
60 if (!class_exists($classname)) { |
|
61 require_once 'Zend/Loader.php'; |
|
62 Zend_Loader::loadClass($classname); |
|
63 } |
|
64 |
|
65 return new $classname($options); |
|
66 } |
|
67 } |