public __construct ( |
||
$collection | instance of Mongo collection | |
$data | array | mongo document |
$options | array | options of object initialization |
public function __construct(Collection $collection, array $data = null, array $options = array())
{
// lisk to collection
$this->collection = $collection;
// configure document with options
$this->options = $options;
// init document
$this->initDelegates();
// execute before construct callable
$this->beforeConstruct();
// initialize with data
parent::__construct($data, $this->getOption('stored'));
// use versioning
if ($this->getOption('versioning')) {
$this->getRevisionManager()->listen();
}
// execure after construct event handlers
$this->eventDispatcher->dispatch('afterConstruct');
}
public function __construct(Collection $revisionsCollection, array $data = null, array $options = array()) { parent::__construct($revisionsCollection, $data, $options); $baseCollectionName = substr($revisionsCollection->getName(), 0, -1 * strlen(RevisionManager::REVISION_COLLECTION_SUFFIX)); $this->baseCollection = $revisionsCollection->getDatabase()->getCollection($baseCollectionName); }