File indexing completed on 2025-01-26 05:24:52

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  * @subpackage StorageService
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 
0022 // require_once 'Zend/Cloud/AbstractFactory.php';
0023 
0024 /**
0025  * @category   Zend
0026  * @package    Zend_Cloud
0027  * @subpackage StorageService
0028  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0029  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0030  */
0031 class Zend_Cloud_StorageService_Factory extends Zend_Cloud_AbstractFactory
0032 {
0033     const STORAGE_ADAPTER_KEY = 'storage_adapter';
0034 
0035     /**
0036      * @var string Interface which adapter must implement to be considered valid
0037      */
0038     protected static $_adapterInterface = 'Zend_Cloud_StorageService_Adapter';
0039     /**
0040      * Constructor
0041      *
0042      * @return void
0043      */
0044     private function __construct()
0045     {
0046         // private ctor - should not be used
0047     }
0048 
0049     /**
0050      * Retrieve StorageService adapter
0051      *
0052      * @param  array $options
0053      * @return Zend_Cloud_StorageService_Adapter 
0054      */
0055     public static function getAdapter($options = array())
0056     {
0057         $adapter = parent::_getAdapter(self::STORAGE_ADAPTER_KEY, $options);
0058         if (!$adapter) {
0059             // require_once 'Zend/Cloud/StorageService/Exception.php';
0060             throw new Zend_Cloud_StorageService_Exception('Class must be specified using the \'' .
0061             self::STORAGE_ADAPTER_KEY . '\' key');
0062         } elseif (!$adapter instanceof self::$_adapterInterface) {
0063             // require_once 'Zend/Cloud/StorageService/Exception.php';
0064             throw new Zend_Cloud_StorageService_Exception(
0065                 'Adapter must implement \'' . self::$_adapterInterface . '\''
0066             );
0067         }
0068         return $adapter;
0069     }
0070 }