public function __construct(Database $database, $collection, Definition $definition = null)
{
// define db
$this->database = $database;
// init mongo collection
if ($collection instanceof \MongoCollection) {
$this->collectionName = $collection->getName();
$this->collection = $collection;
} else {
$this->collectionName = $collection;
}
// init definition
$this->definition = $definition ? $definition : new Definition();
if ($this->documentClass) {
$this->definition->setOption('documentClass', $this->documentClass);
}
if ($this->versioning !== null) {
$this->definition->setOption('versioning', $this->versioning);
}
if ($this->_index) {
$this->definition->setOption('index', $this->_index);
}
if ($this->_queryExpressionClass) {
$this->definition->setOption('expressionClass', $this->_queryExpressionClass);
}
}