web/lib/Zend/Cloud/StorageService/Factory.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     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  * @subpackage StorageService
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  */
       
    21 
       
    22 require_once 'Zend/Cloud/AbstractFactory.php';
       
    23 
       
    24 /**
       
    25  * @category   Zend
       
    26  * @package    Zend_Cloud
       
    27  * @subpackage StorageService
       
    28  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    30  */
       
    31 class Zend_Cloud_StorageService_Factory extends Zend_Cloud_AbstractFactory
       
    32 {
       
    33     const STORAGE_ADAPTER_KEY = 'storage_adapter';
       
    34     
       
    35     /**
       
    36      * @var string Interface which adapter must implement to be considered valid
       
    37      */
       
    38     protected static $_adapterInterface = 'Zend_Cloud_StorageService_Adapter';
       
    39     /**
       
    40      * Constructor
       
    41      * 
       
    42      * @return void
       
    43      */
       
    44     private function __construct()
       
    45     {
       
    46         // private ctor - should not be used
       
    47     }
       
    48     
       
    49     /**
       
    50      * Retrieve StorageService adapter
       
    51      * 
       
    52      * @param  array $options 
       
    53      * @return void
       
    54      */
       
    55     public static function getAdapter($options = array()) 
       
    56     {
       
    57         $adapter = parent::_getAdapter(self::STORAGE_ADAPTER_KEY, $options);
       
    58         if (!$adapter) {
       
    59             require_once 'Zend/Cloud/StorageService/Exception.php';
       
    60             throw new Zend_Cloud_StorageService_Exception('Class must be specified using the \'' .
       
    61             self::STORAGE_ADAPTER_KEY . '\' key');
       
    62         } elseif (!$adapter instanceof self::$_adapterInterface) {
       
    63             require_once 'Zend/Cloud/StorageService/Exception.php';
       
    64             throw new Zend_Cloud_StorageService_Exception(
       
    65                 'Adapter must implement \'' . self::$_adapterInterface . '\''
       
    66             );
       
    67         }
       
    68         return $adapter;
       
    69     }
       
    70 }