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