File indexing completed on 2024-05-19 06:02:50

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Cloud
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  */
0020 
0021 /**
0022  * Abstract factory for Zend_Cloud resources
0023  *
0024  * @category   Zend
0025  * @package    Zend_Cloud
0026  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0027  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0028  */
0029 class Zend_Cloud_AbstractFactory
0030 {
0031     /**
0032      * Constructor
0033      */
0034     private function __construct()
0035     {
0036         // private ctor - should not be used
0037     }
0038 
0039     /**
0040      * Get an individual adapter instance
0041      *
0042      * @param  string $adapterOption
0043      * @param  array|Zend_Config $options
0044      * @return null|Zend_Cloud_DocumentService_Adapter|Zend_Cloud_QueueService_Adapter|Zend_Cloud_StorageService_Adapter
0045      */
0046     protected static function _getAdapter($adapterOption, $options)
0047     {
0048         if ($options instanceof Zend_Config) {
0049             $options = $options->toArray();
0050         }
0051 
0052         if (!isset($options[$adapterOption])) {
0053             return null;
0054         }
0055 
0056         $classname = $options[$adapterOption];
0057         unset($options[$adapterOption]);
0058         if (!class_exists($classname)) {
0059             // require_once 'Zend/Loader.php';
0060             Zend_Loader::loadClass($classname);
0061         }
0062 
0063         return new $classname($options);
0064     }
0065 }