Commit 6e84d2ff authored by Will Banfield's avatar Will Banfield Committed by Jeremy Mikola

Stream registering is now totally transparent to the user

parent 2a99015a
...@@ -21,6 +21,7 @@ class Bucket ...@@ -21,6 +21,7 @@ class Bucket
private $databaseName; private $databaseName;
private $collectionsWrapper; private $collectionsWrapper;
private $options; private $options;
private static $streamWrapper;
/** /**
* Constructs a GridFS bucket. * Constructs a GridFS bucket.
* *
...@@ -50,6 +51,7 @@ class Bucket ...@@ -50,6 +51,7 @@ class Bucket
$this->databaseName = (string) $databaseName; $this->databaseName = (string) $databaseName;
$this->options = $options; $this->options = $options;
$this->collectionsWrapper = new GridFSCollectionsWrapper($manager, $databaseName, $options); $this->collectionsWrapper = new GridFSCollectionsWrapper($manager, $databaseName, $options);
$this->registerStreamWrapper($manager);
} }
/** /**
...@@ -206,4 +208,12 @@ class Bucket ...@@ -206,4 +208,12 @@ class Bucket
} }
return $file; return $file;
} }
private function registerStreamWrapper($manager)
{
if(isset(Bucket::$streamWrapper)){
return;
}
Bucket::$streamWrapper = new \MongoDB\GridFS\StreamWrapper();
Bucket::$streamWrapper->register($manager);
}
} }
...@@ -21,8 +21,6 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase ...@@ -21,8 +21,6 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
$col = new Collection($this->manager, sprintf("%s.%s",$this->getDatabaseName(), $collection)); $col = new Collection($this->manager, sprintf("%s.%s",$this->getDatabaseName(), $collection));
$col->drop(); $col->drop();
} }
$streamWrapper = new \MongoDB\GridFS\StreamWrapper();
$streamWrapper->register($this->manager);
$this->bucket = new \MongoDB\GridFS\Bucket($this->manager, $this->getDatabaseName()); $this->bucket = new \MongoDB\GridFS\Bucket($this->manager, $this->getDatabaseName());
$this->collectionsWrapper = $this->bucket->getCollectionsWrapper(); $this->collectionsWrapper = $this->bucket->getCollectionsWrapper();
} }
......
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