Factory.php 2.2 KB

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