本文整理汇总了PHP中Kdyby\Doctrine\EntityManager::create方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::create方法的具体用法?PHP EntityManager::create怎么用?PHP EntityManager::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kdyby\Doctrine\EntityManager
的用法示例。
在下文中一共展示了EntityManager::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMemoryManager
/**
* @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;
}
示例2: setUp
protected function setUp()
{
$config = new \Kdyby\Doctrine\Configuration();
$mapping = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new \Doctrine\Common\Annotations\AnnotationReader(), [__DIR__ . '/entitites']);
$config->setMetadataDriverImpl($mapping);
$config->setProxyDir(__DIR__ . '/proxy');
$config->setProxyNamespace('Tests\\_ProxyTests');
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
$event = new \Doctrine\Common\EventManager();
$conn = new \Kdyby\Doctrine\Connection(array('dbname' => 'test', 'user' => 'travis', 'password' => '', 'host' => 'localhost', 'driver' => 'pdo_mysql'), new \Doctrine\DBAL\Driver\PDOMySql\Driver(), $config, $event);
$em = \Kdyby\Doctrine\EntityManager::create($conn, $config, $event);
$this->helper = new \WebChemistry\Forms\Doctrine($em);
}
示例3: createMemoryManager
/**
* @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;
}