Esempio n. 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 string $name
  * @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;
     $this->_metadataFactory = new ClassMetadataFactory($this->_config->getMetadataDriverImpl(), $this->_conn->getDatabasePlatform());
     $this->_metadataFactory->setCacheDriver($this->_config->getMetadataCacheImpl());
     $this->_unitOfWork = new UnitOfWork($this);
     $this->_proxyGenerator = new DynamicProxyGenerator($this, $this->_config->getCacheDir());
 }
Esempio n. 2
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;
     $this->_metadataFactory = new ClassMetadataFactory($this);
     $this->_metadataFactory->setCacheDriver($this->_config->getMetadataCacheImpl());
     $this->_unitOfWork = new UnitOfWork($this);
     $this->_proxyFactory = new ProxyFactory($this, $config->getProxyDir(), $config->getProxyNamespace(), $config->getAutoGenerateProxyClasses());
 }
Esempio n. 3
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());
 }
Esempio n. 4
0
 /**
  * @param mixed $classes
  * @return void
  */
 public function setUp()
 {
     $this->doctrine = Zend_Registry::get('container')->getService('doctrine');
     $this->em = $this->doctrine->getEntityManager();
     $this->em->clear();
     $tool = new SchemaTool($this->em);
     $tool->dropDatabase();
     $classes = func_get_args();
     if (!empty($classes)) {
         $metadataFactory = new ClassMetadataFactory();
         $metadataFactory->setEntityManager($this->em);
         $metadataFactory->setCacheDriver(new ArrayCache());
         $metadata = array();
         foreach ((array) $classes as $class) {
             $metadata[] = $metadataFactory->getMetadataFor($class);
         }
         $tool->createSchema($metadata);
     }
 }
Esempio n. 5
0
 /**
  * Set up entity manager
  *
  * @return Doctrine\ORM\EntityManager
  */
 protected function setUpOrm()
 {
     global $application;
     $doctrine = $application->getBootstrap()->getResource('container')->getService('doctrine');
     $orm = $doctrine->getEntityManager();
     $orm->clear();
     $tool = new SchemaTool($orm);
     $tool->dropDatabase();
     $classes = func_get_args();
     if (!empty($classes)) {
         $metadataFactory = new ClassMetadataFactory();
         $metadataFactory->setEntityManager($orm);
         $metadataFactory->setCacheDriver(new Cache());
         $metadata = array();
         foreach ((array) $classes as $class) {
             $metadata[] = $metadataFactory->getMetadataFor($class);
         }
         $tool->createSchema($metadata);
     }
     return $orm;
 }