Skip to content

Commit 008ee4c

Browse files
committed
[HTTP][Session][Mongo] MongoDB driver support
1 parent 39e11f2 commit 008ee4c

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,28 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
6767
* @throws \InvalidArgumentException When MongoClient or Mongo instance not provided
6868
* @throws \InvalidArgumentException When "database" or "collection" not provided
6969
*/
70-
public function __construct($mongo, array $options)
71-
{
72-
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) {
73-
throw new \InvalidArgumentException('MongoClient, Mongo or MongoDB instance required');
74-
}elseif($mongo instanceof \MongoDB\Client && !class_exists('\MongoDB\Collection')){
75-
throw new \InvalidArgumentException('\MongoDB\Collection instance not loaded');
76-
77-
}
78-
79-
if (!isset($options['database']) || !isset($options['collection'])) {
80-
throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler');
81-
}
82-
83-
$this->mongo = $mongo;
84-
85-
$this->options = array_merge(array(
86-
'id_field' => '_id',
87-
'data_field' => 'data',
88-
'time_field' => 'time',
89-
'expiry_field' => 'expires_at',
90-
), $options);
91-
}
70+
public function __construct($mongo, array $options)
71+
{
72+
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) {
73+
throw new \InvalidArgumentException('MongoClient, Mongo or MongoDB instance required');
74+
}elseif($mongo instanceof \MongoDB\Client && !class_exists('\MongoDB\Collection')){
75+
throw new \InvalidArgumentException('\MongoDB\Collection instance not loaded');
76+
77+
}
78+
79+
if (!isset($options['database']) || !isset($options['collection'])) {
80+
throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler');
81+
}
82+
83+
$this->mongo = $mongo;
84+
85+
$this->options = array_merge(array(
86+
'id_field' => '_id',
87+
'data_field' => 'data',
88+
'time_field' => 'time',
89+
'expiry_field' => 'expires_at',
90+
), $options);
91+
}
9292

9393
/**
9494
* {@inheritdoc}

0 commit comments

Comments
 (0)