Doctrine\ODM\MongoDB\DocumentManager::__construct PHP Method

__construct() protected method

Creates a new Document that operates on the given Mongo connection and uses the given Configuration.
protected __construct ( Connection $conn = null, Configuration $config = null, Doctrine\Common\EventManager $eventManager = null )
$conn Doctrine\MongoDB\Connection
$config Configuration
$eventManager Doctrine\Common\EventManager
    protected function __construct(Connection $conn = null, Configuration $config = null, EventManager $eventManager = null)
    {
        $this->config = $config ?: new Configuration();
        $this->eventManager = $eventManager ?: new EventManager();
        $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->unitOfWork = new UnitOfWork($this, $this->eventManager, $this->hydratorFactory);
        $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());
        $this->repositoryFactory = $this->config->getRepositoryFactory();
    }

Usage Example

 public function __construct()
 {
     AnnotationDriver::registerAnnotationClasses();
     $config = new Configuration();
     $config->setProxyDir(app_path() . '/storage/cache/Doctrine/Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(app_path() . '/storage/cache/Doctrine/Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setMetadataDriverImpl(AnnotationDriver::create(app_path() . '/app/Model/Entity'));
     $config->setDefaultDB(config('database.db_name'));
     parent::__construct(new Connection(\Config::get('database.host')), $config);
 }
All Usage Examples Of Doctrine\ODM\MongoDB\DocumentManager::__construct