Commit 81fcefca authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-74: Use array and document classes in default type map

parent afb74871
...@@ -40,6 +40,14 @@ class Client ...@@ -40,6 +40,14 @@ class Client
*/ */
public function __construct($uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = []) public function __construct($uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = [])
{ {
$driverOptions += [
'typeMap' => [
'array' => 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
],
];
if (isset($driverOptions['typeMap']) && ! is_array($driverOptions['typeMap'])) { if (isset($driverOptions['typeMap']) && ! is_array($driverOptions['typeMap'])) {
throw new InvalidArgumentTypeException('"typeMap" driver option', $driverOptions['typeMap'], 'array'); throw new InvalidArgumentTypeException('"typeMap" driver option', $driverOptions['typeMap'], 'array');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment