1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace DoctrineORMModule\Options; |
21
|
|
|
|
22
|
|
|
use Zend\Stdlib\AbstractOptions; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* DBAL Connection options |
26
|
|
|
* |
27
|
|
|
* @license MIT |
28
|
|
|
* @link http://www.doctrine-project.org/ |
29
|
|
|
* @author Kyle Spraggs <[email protected]> |
30
|
|
|
*/ |
31
|
|
|
class DBALConnection extends AbstractOptions |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* Set the configuration key for the Configuration. Configuration key |
35
|
|
|
* is assembled as "doctrine.configuration.{key}" and pulled from |
36
|
|
|
* service locator. |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $configuration = 'orm_default'; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Set the eventmanager key for the EventManager. EventManager key |
44
|
|
|
* is assembled as "doctrine.eventmanager.{key}" and pulled from |
45
|
|
|
* service locator. |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
protected $eventManager = 'orm_default'; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Set the PDO instance, if any, to use. If a string is set |
53
|
|
|
* then the alias is pulled from the service locator. |
54
|
|
|
* |
55
|
|
|
* @var null|string|\PDO |
56
|
|
|
*/ |
57
|
|
|
protected $pdo = null; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Setting the driver is deprecated. You should set the |
61
|
|
|
* driver class directly instead. |
62
|
|
|
* |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
protected $driverClass = 'Doctrine\DBAL\Driver\PDOMySql\Driver'; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Set the wrapper class for the driver. In general, this should not |
69
|
|
|
* need to be changed. |
70
|
|
|
* |
71
|
|
|
* @var string|null |
72
|
|
|
*/ |
73
|
|
|
protected $wrapperClass = null; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Driver specific connection parameters. |
77
|
|
|
* |
78
|
|
|
* @var array |
79
|
|
|
*/ |
80
|
|
|
protected $params = []; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var array |
84
|
|
|
*/ |
85
|
|
|
protected $doctrineTypeMappings = []; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @var array |
89
|
|
|
*/ |
90
|
|
|
protected $doctrineCommentedTypes = []; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $configuration |
94
|
|
|
* @return $this |
95
|
|
|
*/ |
96
|
56 |
|
public function setConfiguration($configuration) |
97
|
|
|
{ |
98
|
56 |
|
$this->configuration = $configuration; |
99
|
|
|
|
100
|
56 |
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
56 |
|
public function getConfiguration() |
107
|
|
|
{ |
108
|
56 |
|
return 'doctrine.configuration.' . $this->configuration; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param string $eventManager |
113
|
|
|
* @return $this |
114
|
|
|
*/ |
115
|
56 |
|
public function setEventManager($eventManager) |
116
|
|
|
{ |
117
|
56 |
|
$this->eventManager = $eventManager; |
118
|
|
|
|
119
|
56 |
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
56 |
|
public function getEventManager() |
126
|
|
|
{ |
127
|
56 |
|
return 'doctrine.eventmanager.' . $this->eventManager; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param array $params |
132
|
|
|
* @return $this |
133
|
|
|
*/ |
134
|
56 |
|
public function setParams($params) |
135
|
|
|
{ |
136
|
56 |
|
$this->params = $params; |
137
|
|
|
|
138
|
56 |
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return array |
143
|
|
|
*/ |
144
|
56 |
|
public function getParams() |
145
|
|
|
{ |
146
|
56 |
|
return $this->params; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param array $doctrineTypeMappings |
151
|
|
|
* @return $this |
152
|
|
|
*/ |
153
|
|
|
public function setDoctrineTypeMappings($doctrineTypeMappings) |
154
|
|
|
{ |
155
|
|
|
$this->doctrineTypeMappings = (array) $doctrineTypeMappings; |
156
|
|
|
|
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* |
162
|
|
|
* @return array |
163
|
|
|
*/ |
164
|
56 |
|
public function getDoctrineTypeMappings() |
165
|
|
|
{ |
166
|
56 |
|
return $this->doctrineTypeMappings; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @param array $doctrineCommentedTypes |
171
|
|
|
* @return $this |
172
|
|
|
*/ |
173
|
2 |
|
public function setDoctrineCommentedTypes(array $doctrineCommentedTypes) |
174
|
|
|
{ |
175
|
2 |
|
$this->doctrineCommentedTypes = $doctrineCommentedTypes; |
176
|
|
|
|
177
|
2 |
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return array |
182
|
|
|
*/ |
183
|
58 |
|
public function getDoctrineCommentedTypes() |
184
|
|
|
{ |
185
|
58 |
|
return $this->doctrineCommentedTypes; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param null|string $driverClass |
190
|
|
|
* @return $this |
191
|
|
|
*/ |
192
|
56 |
|
public function setDriverClass($driverClass) |
193
|
|
|
{ |
194
|
56 |
|
$this->driverClass = $driverClass; |
195
|
|
|
|
196
|
56 |
|
return $this; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @return null|string |
201
|
|
|
*/ |
202
|
56 |
|
public function getDriverClass() |
203
|
|
|
{ |
204
|
56 |
|
return $this->driverClass; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @param null|\PDO|string $pdo |
209
|
|
|
* @return $this |
210
|
|
|
*/ |
211
|
|
|
public function setPdo($pdo) |
212
|
|
|
{ |
213
|
|
|
$this->pdo = $pdo; |
214
|
|
|
|
215
|
|
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @return null|\PDO|string |
220
|
|
|
*/ |
221
|
56 |
|
public function getPdo() |
222
|
|
|
{ |
223
|
56 |
|
return $this->pdo; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @param string $wrapperClass |
228
|
|
|
* @return $this |
229
|
|
|
*/ |
230
|
|
|
public function setWrapperClass($wrapperClass) |
231
|
|
|
{ |
232
|
|
|
$this->wrapperClass = $wrapperClass; |
233
|
|
|
|
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
56 |
|
public function getWrapperClass() |
241
|
|
|
{ |
242
|
56 |
|
return $this->wrapperClass; |
243
|
|
|
} |
244
|
|
|
} |
245
|
|
|
|