Example #1
0
 /**
  * Creates a new Document that operates on the given Mongo connection
  * and uses the given Configuration.
  *
  * @param \Doctrine\MongoDB\Connection|null $conn
  * @param Configuration|null $config
  * @param \Doctrine\Common\EventManager|null $eventManager
  */
 protected function __construct(Connection $conn = null, Configuration $config = null, EventManager $eventManager = null)
 {
     $this->config = $config ?: new Configuration();
     $this->eventManager = $eventManager ?: new EventManager();
     $this->cmd = $this->config->getMongoCmd();
     $this->connection = $conn ?: new Connection(null, array(), $this->config, $this->eventManager);
     $metadataFactoryClassName = $this->config->getClassMetadataFactoryName();
     $this->metadataFactory = new $metadataFactoryClassName();
     $this->metadataFactory->setDocumentManager($this);
     $this->metadataFactory->setConfiguration($this->config);
     if ($cacheDriver = $this->config->getMetadataCacheImpl()) {
         $this->metadataFactory->setCacheDriver($cacheDriver);
     }
     $hydratorDir = $this->config->getHydratorDir();
     $hydratorNs = $this->config->getHydratorNamespace();
     $this->hydratorFactory = new HydratorFactory($this, $this->eventManager, $hydratorDir, $hydratorNs, $this->config->getAutoGenerateHydratorClasses(), $this->config->getMongoCmd());
     $this->unitOfWork = new UnitOfWork($this, $this->eventManager, $this->hydratorFactory, $this->cmd);
     $this->hydratorFactory->setUnitOfWork($this->unitOfWork);
     $this->schemaManager = new SchemaManager($this, $this->metadataFactory);
     $this->proxyFactory = new ProxyFactory($this, $this->config->getProxyDir(), $this->config->getProxyNamespace(), $this->config->getAutoGenerateProxyClasses());
 }
 /**
  * Returns a new QueryProxy class associated to a document name
  * A query proxy is a class responsible for building query based on options,
  * and also retrieve the query results and proxy custom finder calls to the
  * document object
  *
  * @param string $documentName name of the document whose repository will be queried
  * @return QueryProxy
  */
 public function createQueryBuilder($documentName = null)
 {
     return new QueryProxy($this->documentManager, $this->configuration->getMongoCmd(), $documentName);
 }
 public function __construct(BaseCollection $coll, DocumentManager $dm, Configuration $c)
 {
     $this->coll = $coll;
     $this->dm = $dm;
     $this->cmd = $c->getMongoCmd();
 }