|
@@ 273-295 (lines=23) @@
|
| 270 |
|
throw new InvalidArgumentException('Sharding and master-slave connection cannot be used together'); |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
if (!empty($options['slaves'])) { |
| 274 |
|
$nonRewrittenKeys = array( |
| 275 |
|
'driver' => true, 'driverOptions' => true, 'driverClass' => true, |
| 276 |
|
'wrapperClass' => true, 'keepSlave' => true, 'shardChoser' => true, |
| 277 |
|
'platform' => true, 'slaves' => true, 'master' => true, 'shards' => true, |
| 278 |
|
'serverVersion' => true, |
| 279 |
|
// included by safety but should have been unset already |
| 280 |
|
'logging' => true, 'profiling' => true, 'mapping_types' => true, 'platform_service' => true, |
| 281 |
|
); |
| 282 |
|
foreach ($options as $key => $value) { |
| 283 |
|
if (isset($nonRewrittenKeys[$key])) { |
| 284 |
|
continue; |
| 285 |
|
} |
| 286 |
|
$options['master'][$key] = $value; |
| 287 |
|
unset($options[$key]); |
| 288 |
|
} |
| 289 |
|
if (empty($options['wrapperClass'])) { |
| 290 |
|
// Change the wrapper class only if the user does not already forced using a custom one. |
| 291 |
|
$options['wrapperClass'] = 'Doctrine\\DBAL\\Connections\\MasterSlaveConnection'; |
| 292 |
|
} |
| 293 |
|
} else { |
| 294 |
|
unset($options['slaves']); |
| 295 |
|
} |
| 296 |
|
|
| 297 |
|
if (!empty($options['shards'])) { |
| 298 |
|
$nonRewrittenKeys = array( |
|
@@ 297-318 (lines=22) @@
|
| 294 |
|
unset($options['slaves']); |
| 295 |
|
} |
| 296 |
|
|
| 297 |
|
if (!empty($options['shards'])) { |
| 298 |
|
$nonRewrittenKeys = array( |
| 299 |
|
'driver' => true, 'driverOptions' => true, 'driverClass' => true, |
| 300 |
|
'wrapperClass' => true, 'keepSlave' => true, 'shardChoser' => true, |
| 301 |
|
'platform' => true, 'slaves' => true, 'global' => true, 'shards' => true, |
| 302 |
|
// included by safety but should have been unset already |
| 303 |
|
'logging' => true, 'profiling' => true, 'mapping_types' => true, 'platform_service' => true, |
| 304 |
|
); |
| 305 |
|
foreach ($options as $key => $value) { |
| 306 |
|
if (isset($nonRewrittenKeys[$key])) { |
| 307 |
|
continue; |
| 308 |
|
} |
| 309 |
|
$options['global'][$key] = $value; |
| 310 |
|
unset($options[$key]); |
| 311 |
|
} |
| 312 |
|
if (empty($options['wrapperClass'])) { |
| 313 |
|
// Change the wrapper class only if the user does not already forced using a custom one. |
| 314 |
|
$options['wrapperClass'] = 'Doctrine\\DBAL\\Sharding\\PoolingShardConnection'; |
| 315 |
|
} |
| 316 |
|
} else { |
| 317 |
|
unset($options['shards']); |
| 318 |
|
} |
| 319 |
|
|
| 320 |
|
return $options; |
| 321 |
|
} |