File indexing completed on 2024-06-16 05:29:54

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 QueueService
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 QueueService
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_QueueService_Factory extends Zend_Cloud_AbstractFactory
0032 {
0033     const QUEUE_ADAPTER_KEY = 'queue_adapter';
0034 
0035     /**
0036      * @var string Interface which adapter must implement to be considered valid
0037      */
0038     protected static $_adapterInterface = 'Zend_Cloud_QueueService_Adapter';
0039 
0040     /**
0041      * Constructor
0042      */
0043     private function __construct()
0044     {
0045         // private ctor - should not be used
0046     }
0047 
0048     /**
0049      * Retrieve QueueService adapter
0050      *
0051      * @param  array $options
0052      * @return null|Zend_Cloud_DocumentService_Adapter|Zend_Cloud_QueueService_Adapter|Zend_Cloud_StorageService_Adapter
0053      * @throws Zend_Cloud_QueueService_Exception
0054      */
0055     public static function getAdapter($options = array())
0056     {
0057         $adapter = parent::_getAdapter(self::QUEUE_ADAPTER_KEY, $options);
0058         if (!$adapter) {
0059             // require_once 'Zend/Cloud/QueueService/Exception.php';
0060             throw new Zend_Cloud_QueueService_Exception('Class must be specified using the \'' .
0061             self::QUEUE_ADAPTER_KEY . '\' key');
0062         } elseif (!$adapter instanceof self::$_adapterInterface) {
0063             // require_once 'Zend/Cloud/QueueService/Exception.php';
0064             throw new Zend_Cloud_QueueService_Exception(
0065                 'Adapter must implement \'' . self::$_adapterInterface . '\''
0066             );
0067         }
0068         return $adapter;
0069     }
0070 }