Factory.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 DocumentService
  18. * @copyright Copyright (c) 2005-2015 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. * Class implementing working with Azure queries in a structured way
  24. *
  25. * TODO Look into preventing a query injection attack.
  26. *
  27. * @category Zend
  28. * @package Zend_Cloud
  29. * @subpackage DocumentService
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Cloud_DocumentService_Factory extends Zend_Cloud_AbstractFactory
  34. {
  35. const DOCUMENT_ADAPTER_KEY = 'document_adapter';
  36. /**
  37. * @var string Interface which adapter must implement to be considered valid
  38. */
  39. protected static $_adapterInterface = 'Zend_Cloud_DocumentService_Adapter';
  40. /**
  41. * Constructor
  42. *
  43. * @return void
  44. */
  45. private function __construct()
  46. {
  47. // private ctor - should not be used
  48. }
  49. /**
  50. * Retrieve an adapter instance
  51. *
  52. * @param array $options
  53. * @return void
  54. */
  55. public static function getAdapter($options = array())
  56. {
  57. $adapter = parent::_getAdapter(self::DOCUMENT_ADAPTER_KEY, $options);
  58. if (!$adapter) {
  59. require_once 'Zend/Cloud/DocumentService/Exception.php';
  60. throw new Zend_Cloud_DocumentService_Exception(
  61. 'Class must be specified using the \''
  62. . self::DOCUMENT_ADAPTER_KEY . '\' key'
  63. );
  64. } elseif (!$adapter instanceof self::$_adapterInterface) {
  65. require_once 'Zend/Cloud/DocumentService/Exception.php';
  66. throw new Zend_Cloud_DocumentService_Exception(
  67. 'Adapter must implement \'' . self::$_adapterInterface . '\''
  68. );
  69. }
  70. return $adapter;
  71. }
  72. }