File indexing completed on 2024-12-22 05:36:31
0001 <?php 0002 /** 0003 * @category Zend 0004 * @package Zend_Cloud 0005 * @subpackage Infrastructure 0006 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0007 * @license http://framework.zend.com/license/new-bsd New BSD License 0008 */ 0009 0010 // require_once 'Zend/Cloud/AbstractFactory.php'; 0011 0012 0013 /** 0014 * Factory for infrastructure adapters 0015 * 0016 * @package Zend_Cloud 0017 * @subpackage Infrastructure 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 class Zend_Cloud_Infrastructure_Factory extends Zend_Cloud_AbstractFactory 0022 { 0023 const INFRASTRUCTURE_ADAPTER_KEY = 'infrastructure_adapter'; 0024 0025 /** 0026 * @var string Interface which adapter must implement to be considered valid 0027 */ 0028 protected static $_adapterInterface = 'Zend_Cloud_Infrastructure_Adapter'; 0029 0030 /** 0031 * Constructor 0032 * 0033 * Private ctor - should not be used 0034 * 0035 * @return void 0036 */ 0037 private function __construct() 0038 { 0039 } 0040 0041 /** 0042 * Retrieve an adapter instance 0043 * 0044 * @param array $options 0045 * @return void 0046 */ 0047 public static function getAdapter($options = array()) 0048 { 0049 $adapter = parent::_getAdapter(self::INFRASTRUCTURE_ADAPTER_KEY, $options); 0050 0051 if (!$adapter) { 0052 // require_once 'Zend/Cloud/Infrastructure/Exception.php'; 0053 throw new Zend_Cloud_Infrastructure_Exception(sprintf( 0054 'Class must be specified using the "%s" key', 0055 self::INFRASTRUCTURE_ADAPTER_KEY 0056 )); 0057 } elseif (!$adapter instanceof self::$_adapterInterface) { 0058 // require_once 'Zend/Cloud/Infrastructure/Exception.php'; 0059 throw new Zend_Cloud_Infrastructure_Exception(sprintf( 0060 'Adapter must implement "%s"', self::$_adapterInterface 0061 )); 0062 } 0063 return $adapter; 0064 } 0065 }