/** * @return Kdyby\Doctrine\EntityManager */ protected function createMemoryManager($classNames = NULL, $createSchema = TRUE) { $conf = ['driver' => 'pdo_sqlite', 'memory' => TRUE]; $connection = new Kdyby\Doctrine\Connection($conf, new Driver()); $config = new Kdyby\Doctrine\Configuration(); $cache = new ArrayCache(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $config->setProxyDir(TEMP_DIR); $config->setProxyNamespace('TestProxy'); $config->setDefaultRepositoryClassName('Kdyby\\Doctrine\\EntityRepository'); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([__DIR__ . '/Model/', VENDOR_DIR], FALSE)); $em = Kdyby\Doctrine\EntityManager::create($connection, $config); $em->getEventManager()->addEventSubscriber(new SortableListener()); if ($createSchema === FALSE) { return $em; } $schemaTool = new SchemaTool($em); if ($classNames !== NULL) { $meta = []; foreach ((array) $classNames as $className) { $meta[] = $em->getClassMetadata($className); } } else { $meta = $em->getMetadataFactory()->getAllMetadata(); } $schemaTool->createSchema($meta); return $em; }
/** * @return Kdyby\Doctrine\EntityManager */ protected function createMemoryManager($createSchema = TRUE) { $conf = ['driver' => 'pdo_sqlite', 'memory' => TRUE]; $connection = new Kdyby\Doctrine\Connection($conf, new Driver()); $config = new Kdyby\Doctrine\Configuration(); $cache = new ArrayCache(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $config->setProxyDir(TEMP_DIR); $config->setProxyNamespace('TestProxy'); $config->setDefaultRepositoryClassName(Kdyby\Doctrine\EntityDao::class); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([__DIR__], FALSE)); $em = Kdyby\Doctrine\EntityManager::create($connection, $config); if ($createSchema === FALSE) { return $em; } $schemaTool = new SchemaTool($em); $meta = $em->getMetadataFactory()->getAllMetadata(); $schemaTool->createSchema($meta); return $em; }