Example #1
0
 /**
  * Creates a new EntityManager that operates on the given database connection
  * and uses the given Configuration and EventManager implementations.
  *
  * @param \Doctrine\DBAL\Connection     $conn
  * @param \Doctrine\ORM\Configuration   $config
  * @param \Doctrine\Common\EventManager $eventManager
  */
 protected function __construct(Connection $conn, Configuration $config, EventManager $eventManager)
 {
     $this->conn = $conn;
     $this->config = $config;
     $this->eventManager = $eventManager;
     $metadataFactoryClassName = $config->getClassMetadataFactoryName();
     $this->metadataFactory = new $metadataFactoryClassName();
     $this->metadataFactory->setEntityManager($this);
     $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());
     $this->repositoryFactory = $config->getRepositoryFactory();
     $this->unitOfWork = new UnitOfWork($this);
     $this->proxyFactory = new ProxyFactory($this, $config->getProxyDir(), $config->getProxyNamespace(), $config->getAutoGenerateProxyClasses());
     if ($config->isSecondLevelCacheEnabled()) {
         $cacheClass = $config->getSecondLevelCacheConfiguration()->getCacheClassName();
         $this->cache = new $cacheClass($this);
     }
 }