|
1 <?php |
|
2 /** |
|
3 * @category Zend |
|
4 * @package Zend_Cloud |
|
5 * @subpackage Infrastructure |
|
6 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
7 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
8 */ |
|
9 |
|
10 require_once 'Zend/Cloud/AbstractFactory.php'; |
|
11 |
|
12 |
|
13 /** |
|
14 * Factory for infrastructure adapters |
|
15 * |
|
16 * @package Zend_Cloud |
|
17 * @subpackage Infrastructure |
|
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 */ |
|
21 class Zend_Cloud_Infrastructure_Factory extends Zend_Cloud_AbstractFactory |
|
22 { |
|
23 const INFRASTRUCTURE_ADAPTER_KEY = 'infrastructure_adapter'; |
|
24 |
|
25 /** |
|
26 * @var string Interface which adapter must implement to be considered valid |
|
27 */ |
|
28 protected static $_adapterInterface = 'Zend_Cloud_Infrastructure_Adapter'; |
|
29 |
|
30 /** |
|
31 * Constructor |
|
32 * |
|
33 * Private ctor - should not be used |
|
34 * |
|
35 * @return void |
|
36 */ |
|
37 private function __construct() |
|
38 { |
|
39 } |
|
40 |
|
41 /** |
|
42 * Retrieve an adapter instance |
|
43 * |
|
44 * @param array $options |
|
45 * @return void |
|
46 */ |
|
47 public static function getAdapter($options = array()) |
|
48 { |
|
49 $adapter = parent::_getAdapter(self::INFRASTRUCTURE_ADAPTER_KEY, $options); |
|
50 |
|
51 if (!$adapter) { |
|
52 require_once 'Zend/Cloud/Infrastructure/Exception.php'; |
|
53 throw new Zend_Cloud_Infrastructure_Exception(sprintf( |
|
54 'Class must be specified using the "%s" key', |
|
55 self::INFRASTRUCTURE_ADAPTER_KEY |
|
56 )); |
|
57 } elseif (!$adapter instanceof self::$_adapterInterface) { |
|
58 require_once 'Zend/Cloud/Infrastructure/Exception.php'; |
|
59 throw new Zend_Cloud_Infrastructure_Exception(sprintf( |
|
60 'Adapter must implement "%s"', self::$_adapterInterface |
|
61 )); |
|
62 } |
|
63 return $adapter; |
|
64 } |
|
65 } |