當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityManager::create方法代碼示例

本文整理匯總了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;
 }
開發者ID:librette,項目名稱:doctrine-sortable,代碼行數:32,代碼來源:EMTest.php

示例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);
 }
開發者ID:webchemistry,項目名稱:forms-doctrine,代碼行數:13,代碼來源:ToArrayTest.php

示例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;
 }
開發者ID:librette,項目名稱:doctrine-queries,代碼行數:24,代碼來源:EntityManagerTest.php


注:本文中的Kdyby\Doctrine\EntityManager::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。