本文整理汇总了PHP中Doctrine\ORM\Tools\Setup类的典型用法代码示例。如果您正苦于以下问题:PHP Setup类的具体用法?PHP Setup怎么用?PHP Setup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Setup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
require APPPATH . 'config/database.php';
$dbParams = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database'], 'charset' => $db['default']['char_set'], 'driverOptions' => array('charset' => $db['default']['char_set']));
$isDevMode = true;
$config = new Configuration();
$setup = new Setup();
$config = $setup->createAnnotationMetadataConfiguration(array(APPPATH . "models"), $isDevMode);
$config = $setup->createYAMLMetadataConfiguration(array(APPPATH . "models/Yaml"), $isDevMode);
$this->em = EntityManager::create($dbParams, $config);
}
开发者ID:vinny-silveira,项目名称:codeigniter-doctrine-twig,代码行数:11,代码来源:Doctrine.php
示例2: getConfig
public static function getConfig($appName, $modelNames = null)
{
$mappingDriver = new Tinebase_Record_DoctrineMappingDriver();
if (!$modelNames) {
$modelNames = array();
foreach ($mappingDriver->getAllClassNames() as $modelName) {
$modelConfig = $modelName::getConfiguration();
if ($modelConfig->getApplName() == $appName) {
$modelNames[] = $modelName;
}
}
}
$tableNames = array();
foreach ($modelNames as $modelName) {
$modelConfig = $modelName::getConfiguration();
if (!$mappingDriver->isTransient($modelName)) {
throw new Setup_Exception('Model not yet doctrine2 ready');
}
$tableNames[] = SQL_TABLE_PREFIX . Tinebase_Helper::array_value('name', $modelConfig->getTable());
}
$config = Setup::createConfiguration();
$config->setMetadataDriverImpl($mappingDriver);
$config->setFilterSchemaAssetsExpression('/' . implode('|', $tableNames) . '/');
return $config;
}
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:25,代码来源:SchemaTool.php
示例3: setUp
public function setUp()
{
$this->_oldEntityManager = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager();
$this->_oldAuditedClassNames = \SoliantEntityAudit\Module::getModuleOptions()->getAuditedClassNames();
$this->_oldJoinClasses = \SoliantEntityAudit\Module::getModuleOptions()->resetJoinClasses();
$isDevMode = false;
$config = Setup::createConfiguration($isDevMode, null, null);
$chain = new DriverChain();
// Use ZFC User for authentication tests
$chain->addDriver(new XmlDriver(__DIR__ . '/../../../vendor/zf-commons/zfc-user-doctrine-orm/config/xml/zfcuser'), 'ZfcUser\\Entity');
$chain->addDriver(new XmlDriver(__DIR__ . '/../../../vendor/zf-commons/zfc-user-doctrine-orm/config/xml/zfcuserdoctrineorm'), 'ZfcUserDoctrineORM\\Entity');
$chain->addDriver(new StaticPHPDriver(__DIR__ . "/../Models"), 'SoliantEntityAuditTest\\Models\\LogRevision');
$chain->addDriver(new AuditDriver('.'), 'SoliantEntityAudit\\Entity');
$config->setMetadataDriverImpl($chain);
// Replace entity manager
$moduleOptions = \SoliantEntityAudit\Module::getModuleOptions();
$conn = array('driver' => 'pdo_sqlite', 'memory' => true);
$moduleOptions->setAuditedClassNames(array('SoliantEntityAuditTest\\Models\\LogRevision\\Album' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\Performer' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\Song' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\SingleCoverArt' => array()));
$entityManager = EntityManager::create($conn, $config);
$moduleOptions->setEntityManager($entityManager);
$schemaTool = new SchemaTool($entityManager);
// Add auditing listener
$entityManager->getEventManager()->addEventSubscriber(new LogRevision());
$sql = $schemaTool->getUpdateSchemaSql($entityManager->getMetadataFactory()->getAllMetadata());
#print_r($sql);die();
$schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
$this->_em = $entityManager;
}
开发者ID:VOONWerbeagentur,项目名称:SoliantEntityAudit,代码行数:28,代码来源:LogRevisionTest.php
示例4: __construct
public function __construct(Configuration $configuration)
{
$driver = new PHPDriver(__DIR__ . '/../Mapping/');
$config = Setup::createConfiguration($configuration['debug']);
$config->setMetadataDriverImpl($driver);
$this->entityManager = EntityManager::create($configuration['database']['write_connection'], $config);
}
开发者ID:NigelGreenway,项目名称:Architectural-Playground,代码行数:7,代码来源:EntityManagerAdaptor.php
示例5: register
public function register(Application $app)
{
$app['orm.em.paths'] = $app->share(function () {
return array();
});
$app['orm.event_manager'] = $app->share(function () use($app) {
return new EventManager();
});
$app['orm.config'] = $app->share(function () use($app) {
return Setup::createConfiguration($app['debug']);
});
$app['orm.anotation_reader'] = $app->share(function () use($app) {
$annotationReader = new AnnotationReader();
$cache = $app['orm.config']->getMetadataCacheImpl();
return new CachedReader($annotationReader, $cache);
});
$app['orm.default_anotation_driver'] = $app->share(function () use($app) {
AnnotationRegistry::registerFile($app['vendor_dir'] . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
return new AnnotationDriver($app['orm.anotation_reader'], $app['orm.em.paths']);
});
$app['orm.em'] = $app->share(function () use($app) {
$annotationReader = $app['orm.anotation_reader'];
$eventManager = $app['orm.event_manager'];
$driverChain = new MappingDriverChain();
$driverChain->setDefaultDriver($app['orm.default_anotation_driver']);
DoctrineExtensions::registerMappingIntoDriverChainORM($driverChain, $annotationReader);
$loggableListener = new LoggableListener();
$loggableListener->setAnnotationReader($annotationReader);
$loggableListener->setUsername('admin');
$eventManager->addEventSubscriber($loggableListener);
$config = $app['orm.config'];
$config->setMetadataDriverImpl($driverChain);
return EntityManager::create($app['db.default_options'], $config, $eventManager);
});
}
开发者ID:xesenix,项目名称:bdf2-library,代码行数:35,代码来源:ORMServiceProvider.php
示例6: register
public function register(Application $app)
{
$paths = array(realpath($app['config']['doctrine']['paths']['entity']));
$isDevMode = $app['config']['doctrine']['devMode'];
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false);
$app['doctrine'] = EntityManager::create($app['config']['doctrine']['db'], $config);
}
开发者ID:joeyrivera,项目名称:phpug-silex-intro,代码行数:7,代码来源:Doctrine.php
示例7: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('config');
// The parameters in Doctrine 2 and ZF2 are slightly different.
// Below is an example how we can reuse the db settings
$doctrineDbConfig = (array) $config['db'];
$doctrineDbConfig['driver'] = strtolower($doctrineDbConfig['driver']);
if (!isset($doctrineDbConfig['dbname'])) {
$doctrineDbConfig['dbname'] = $doctrineDbConfig['database'];
}
if (!isset($doctrineDbConfig['host'])) {
$doctrineDbConfig['host'] = $doctrineDbConfig['hostname'];
}
if (!isset($doctrineDbConfig['user'])) {
$doctrineDbConfig['user'] = $doctrineDbConfig['username'];
}
$doctrineConfig = Setup::createAnnotationMetadataConfiguration($config['doctrine']['entity_path'], true);
$entityManager = DoctrineEntityManager::create($doctrineDbConfig, $doctrineConfig);
if (isset($config['doctrine']['initializers'])) {
$eventManager = $entityManager->getEventManager();
foreach ($config['doctrine']['initializers'] as $initializer) {
$eventClass = new DoctrineEvent(new $initializer(), $serviceLocator);
$eventManager->addEventListener(\Doctrine\ORM\Events::postLoad, $eventClass);
}
}
if ($serviceLocator->has('doctrine-profiler')) {
$profiler = $serviceLocator->get('doctrine-profiler');
$entityManager->getConfiguration()->setSQLLogger($profiler);
}
return $entityManager;
}
开发者ID:gsokolowski,项目名称:learnzf2,代码行数:31,代码来源:EntityManager.php
示例8: getEntityManager
/**
* @return EntityManager
*/
public function getEntityManager()
{
if (!$this->entityManager instanceof EntityManager) {
$this->entityManager = EntityManager::create($this->getConfiguration()->get('database'), Setup::createAnnotationMetadataConfiguration([$this->rootPath . '/src/Classes/Entities/', __DIR__ . '/Domain/Entities/'], true));
}
return $this->entityManager;
}
开发者ID:smichaelsen,项目名称:php-salad-bowl,代码行数:10,代码来源:Bowl.php
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$dbName = $input->getArgument('dbname');
$path = $input->getOption('path');
$extensionKey = $input->getOption('extension-key');
$connectionParams = array('dbname' => $dbName, 'user' => $input->getOption('user'), 'password' => $input->getOption('password'), 'host' => $input->getOption('host'), 'driver' => $input->getOption('driver'), 'port' => $input->getOption('port'));
$config = Setup::createAnnotationMetadataConfiguration(array('.'), false);
$em = EntityManager::create($connectionParams, $config);
$em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
$cmf = new DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em);
if (is_null($extensionKey)) {
$extensionKey = $dbName;
if (self::DEFAULT_PATH != $path) {
$extensionKey = array_pop(explode(DIRECTORY_SEPARATOR, $path));
}
}
$exporter = new ExtbaseExporter($cmf);
$exporter->setExtensionKey($extensionKey);
$exporter->setPath($input->getOption('path'));
self::mapDefaultInputOptions($exporter, $input);
$output->writeln(sprintf('Exporting database schema "<info>%s</info>".', $dbName));
$result = $exporter->exportJson();
foreach ($exporter->getLogs() as $log) {
$output->writeln($log);
}
return $result ? 0 : 1;
}
开发者ID:edrush,项目名称:extbaser,代码行数:28,代码来源:ExportExtbaseCommand.php
示例10: __construct
private function __construct()
{
$settings = Setup::getSettings();
$config = \Doctrine\ORM\Tools\Setup::createXMLMetadataConfiguration([__DIR__ . '/../Mapper', 'Bh/Mapper'], $settings['DevMode']);
$conn = array('driver' => 'pdo_mysql', 'user' => $settings['DbUser'], 'password' => $settings['DbPass'], 'dbname' => $settings['DbName']);
self::$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
}
开发者ID:uglybob,项目名称:bh.net,代码行数:7,代码来源:Mapper.php
示例11: __construct
public function __construct($sm, $params = array())
{
$this->sm = $sm;
$path = $sm->get('pegase.core.path');
foreach ($params['entities_folders'] as $i => $f) {
$params['entities_folders'][$i] = $path->get_path($f);
}
$this->db_params = $params['database'];
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration($params['entities_folders'], $isDevMode);
$this->em = EntityManager::create($params['database'], $config);
/*
// on vérifie la validité des mappings
$validator = new SchemaValidator($this->em);
$errors = $validator->validateMapping();
if(count($errors) > 0) {
// Lots of errors!
echo implode("\n\n", $errors);
}
else
echo "Les mappings sont ok.\n";
*/
$this->schema = new Schema($sm, $this);
$this->database = new Database($sm, $this);
$this->entity = new Entity($sm, $this);
}
开发者ID:nativgames,项目名称:pegase-external-doctrine2-orm,代码行数:28,代码来源:DoctrineService.php
示例12: addEntityManager
/**
* This method is used to add an entity manager to the doctrine service.
* @param $id string The id you would like to store with the entity manager.
* @param ulfberht\module\doctrine\config $config The doctrine configuration for
* the entity manager.
* @return void
*/
public function addEntityManager($id, config $config)
{
$development = $config->develop ? true : false;
$cache = $config->enableCache ? new ArrayCache() : null;
//setup type of metadata reading
switch ($config->type) {
case 'annotation':
$docConfig = Setup::createAnnotationMetadataConfiguration($config->paths, $development, null, $cache);
break;
case 'xml':
$docConfig = Setup::createXMLMetadataConfiguration($config->paths, $development, null, $cache);
break;
case 'yaml':
$docConfig = Setup::createYAMLMetadataConfiguration($config->paths, $development, null, $cache);
break;
}
//setup caching
if (!is_null($cache)) {
$docConfig->setQueryCacheImpl($cache);
$docConfig->setMetadataCacheImpl($cache);
}
//setup database connection
$dbConnInfo = array('driver' => $config->database->driver, 'host' => $config->database->host, 'dbname' => $config->database->name, 'user' => $config->database->user, 'password' => $config->database->password);
//store entity manager
$this->_doctrineEntityMangers[$id] = EntityManager::create($dbConnInfo, $docConfig);
}
开发者ID:ua1-labs,项目名称:ulfberht-application,代码行数:33,代码来源:doctrine.php
示例13: __construct
public function __construct()
{
$this->setRoot("/var/www/html/uan/");
$this->setEntidade(array($this->getRoot() . "models/"));
$this->setIsDevMode(true);
$mode = "DESENVOLVIMENTO";
$config = Setup::createAnnotationMetadataConfiguration($this->getEntidade(), $this->getIsDevMode(), NULL, NULL, FALSE);
if ($mode == "DESENVOLVIMENTO") {
$cache = new \Doctrine\Common\Cache\ArrayCache();
} else {
$cache = new \Doctrine\Common\Cache\ApcCache();
}
$config = new Configuration();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver($this->getRoot() . 'models/');
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir($this->getRoot() . 'proxies/');
$config->setProxyNamespace('proxies');
if ($mode == "DESENVOLVIMENTO") {
$config->setAutoGenerateProxyClasses(true);
} else {
$config->setAutoGenerateProxyClasses(false);
}
$config = Setup::createAnnotationMetadataConfiguration($this->getEntidade(), $this->getIsDevMode(), NULL, NULL, FALSE);
$dbParams = array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'ceafie', 'charset' => 'utf8', 'driverOptions' => array(1002 => 'SET NAMES utf8'));
$this->em = EntityManager::create($dbParams, $config);
$loader = new ClassLoader('Entity', __DIR__ . '/models');
$loader->register();
}
开发者ID:ndongalameck,项目名称:ceafieUan,代码行数:30,代码来源:Doctrine.php
示例14: __construct
public function __construct()
{
$yamlParser = new Parser();
$dbParams = $yamlParser->parse(file_get_contents(__DIR__ . '/parameters.yml'));
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . '/../Entity'), true);
$this->em = EntityManager::create($dbParams['database'], $config);
}
开发者ID:karolbisztyga,项目名称:websockets,代码行数:7,代码来源:cli-config.php
示例15: __construct
/**
* @param array $database
* @throws \Exception
*/
public function __construct($database = [])
{
$this->db = $database;
foreach ($this->db as $key => $db) {
$this->allDb[$key] = function () use($db) {
$db['dev'] = isset($db['dev']) && $db['dev'] ? true : false;
if (isset($db['db_url'])) {
$dbParams = array('url' => $db['db_url']);
} else {
if (!isset($db['driver']) || !isset($db['user']) || !isset($db['pass']) || !isset($db['host']) || !isset($db['db'])) {
throw new \Exception('Missing arguments for doctrine constructor');
}
$dbParams = array('driver' => $this->getDriver($db['driver']), 'user' => $db['user'], 'password' => $db['pass'], 'host' => $db['host'], 'dbname' => $db['db'], 'charset' => isset($db['charset']) ? $db['charset'] : 'utf8');
}
$evm = new EventManager();
if (isset($db['prefix'])) {
$tablePrefix = new TablePrefix($db['prefix']);
$evm->addEventListener(Events::loadClassMetadata, $tablePrefix);
}
$config = Setup::createAnnotationMetadataConfiguration($db['path'], $db['dev']);
if (!$db['dev']) {
$config->setQueryCacheImpl($db['cache']);
$config->setResultCacheImpl($db['cache']);
$config->setMetadataCacheImpl($db['cache']);
}
if (isset($db['functions']) && !empty($db['functions'])) {
$config->setCustomDatetimeFunctions($db['functions']['customDatetimeFunctions']);
$config->setCustomNumericFunctions($db['functions']['customNumericFunctions']);
$config->setCustomStringFunctions($db['functions']['customStringFunctions']);
}
return EntityManager::create($dbParams, $config, $evm);
};
}
}
开发者ID:jetfirephp,项目名称:db,代码行数:38,代码来源:DoctrineConstructor.php
示例16: setUp
protected function setUp()
{
$pathToEntities = [__DIR__ . '/Entity'];
$isDevMode = true;
$connectionParams = array('user' => 'user', 'password' => 'password', 'driver' => 'pdo_sqlite', 'memory' => true);
$config = Setup::createConfiguration($isDevMode);
$driver = new AnnotationDriver(new AnnotationReader(), $pathToEntities);
AnnotationRegistry::registerLoader('class_exists');
$config->setMetadataDriverImpl($driver);
$this->em = EntityManager::create($connectionParams, $config);
/*
* Устанавливаем фикстуры, знаю что можно это сделать более универсально, но ... в данном контексте мне больше и не надо
*/
$conn = $this->em->getConnection();
$conn->exec("CREATE TABLE clients (id INTEGER PRIMARY KEY, name TEXT, surname TEXT);");
$conn->exec("CREATE TABLE authors (id INTEGER PRIMARY KEY, name TEXT, surname TEXT);");
$conn->exec("CREATE TABLE books (id INTEGER, owner_id INTEGER, name TEXT, surname TEXT, CONSTRAINT 'pk' PRIMARY KEY (id, owner_id));");
$conn->exec("INSERT INTO clients (name,surname) VALUES('Nikita','Sapogov')");
$conn->exec("INSERT INTO clients (name,surname) VALUES('Alex','Ivanov')");
$conn->exec("INSERT INTO clients (name,surname) VALUES('Sura','Soir')");
$conn->exec("INSERT INTO clients (name,surname) VALUES('Vasya','Poliakocv')");
$conn->exec("INSERT INTO books (id, owner_id, name) VALUES (1,1,'SuperBookNAme')");
$conn->exec("INSERT INTO books (id, owner_id, name) VALUES (2,15,'SuperBookNAme2')");
$conn->exec("INSERT INTO books (id, owner_id, name) VALUES (3,3,'SuperBookNAme3')");
}
开发者ID:amstaffix,项目名称:common-doctrine-orm,代码行数:25,代码来源:TestCase.php
示例17: setUp
protected function setUp()
{
parent::setUp();
$this->connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::SQLITE_PATH], new Configuration());
$config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/../..'], true);
$this->entityManager = EntityManager::create($this->connection, $config);
}
开发者ID:alexdpy,项目名称:acl,代码行数:7,代码来源:DoctrineOrmAclFilterTest.php
示例18: setUp
/**
* Initializes the database (once).
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\Tools\ToolsException
*/
protected function setUp()
{
if (null === static::$_conn) {
$dbPath = __DIR__ . '/../../../db.sqlite';
if (file_exists($dbPath)) {
unlink($dbPath);
}
$params = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
static::$_conn = DriverManager::getConnection($params);
static::$_conn->getConfiguration()->setSQLLogger(null);
}
if (null === static::$_em) {
$paths = [__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/ORM/Resources/mapping'];
$isDevMode = true;
$config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
$em = EntityManager::create(static::$_conn, $config);
$classes = [];
foreach (static::$_classes as $class) {
array_push($classes, $em->getClassMetadata($class));
}
$schemaTool = new SchemaTool($em);
$schemaTool->dropSchema($classes);
$schemaTool->createSchema($classes);
// Load fixtures
$loader = new Loader();
$loader->loadFromDirectory(__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/Fixtures');
$purger = new ORMPurger();
$executor = new ORMExecutor($em, $purger);
$executor->execute($loader->getFixtures());
static::$_em = $em;
}
}
开发者ID:ekyna,项目名称:commerce,代码行数:39,代码来源:DatabaseTestCase.php
示例19: createService
/**
* @param ServiceLocatorInterface $serviceLocator
* @return \Doctrine\ORM\EntityManager
* @throws \Doctrine\ORM\ORMException
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('config');
//set the Doctrine configuration array
$doctrineDbSettings = (array) $config['db'];
$doctrineDbSettings['driver'] = strtolower($config['db']['driver']);
$doctrineDbSettings['dbname'] = isset($config['db']['database']) ? $config['db']['database'] : null;
$doctrineDbSettings['host'] = isset($config['db']['hostname']) ? $config['db']['hostname'] : null;
$doctrineDbSettings['user'] = isset($config['db']['username']) ? $config['db']['username'] : null;
$proxyPath = isset($config['doctrine']['proxy_dir']) ? $config['doctrine']['proxy_dir'] : null;
$isDevMode = isset($config['doctrine']['is_dev_mode']) ? $config['doctrine']['is_dev_mode'] : false;
$doctrineConfig = Setup::createAnnotationMetadataConfiguration($config['doctrine']['entity_path'], $isDevMode, $proxyPath);
$doctrineConfig->setAutoGenerateProxyClasses(true);
$doctrineEntityManager = DocEManager::create($doctrineDbSettings, $doctrineConfig);
if (isset($config['doctrine']['initializers'])) {
$eventManager = $doctrineEntityManager->getEventManager();
foreach ($config['doctrine']['initializers'] as $initializer) {
$eventClass = new DoctrineEvent(new $initializer(), $serviceLocator);
$eventManager->addEventListener(\Doctrine\ORM\Events::postLoad, $eventClass);
}
}
if ($doctrineDbSettings['driver'] == 'pdo_sqlite') {
//it is very important to make sure foreign keys are on with SQLite
$query = $doctrineEntityManager->createNativeQuery("pragma foreign_keys=1", new \Doctrine\ORM\Query\ResultSetMapping());
$query->execute();
}
return $doctrineEntityManager;
}
开发者ID:veniva,项目名称:zcms,代码行数:33,代码来源:EntityManager.php
示例20: setUp
public function setUp()
{
// register our custom type
if (!Type::hasType('hstore')) {
Type::addType('hstore', 'EasyBib\\Doctrine\\Types\\Hstore');
}
$isDevMode = true;
$doctrineConfig = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . '/Entity'), $isDevMode);
// database configuration parameters
$rootTestsFolder = dirname(dirname(dirname(dirname(__DIR__))));
$this->isTravis = getenv("TRAVIS");
if (file_exists($rootTestsFolder . '/db-config.php')) {
$dbConfig = (include $rootTestsFolder . '/db-config.php');
} elseif (false !== $this->isTravis) {
$dbConfig = (include $rootTestsFolder . '/db-config-travisci.php');
} else {
throw new \RuntimeException("No database configuration found.");
}
// create the entity manager
$this->em = EntityManager::create($dbConfig, $doctrineConfig);
// enable 'hstore'
$this->em->getConnection()->exec("CREATE EXTENSION IF NOT EXISTS hstore");
// register type with DBAL
$this->em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('hstore', 'hstore');
// make the PersistentObject happy
PersistentObject::setObjectManager($this->em);
// create table
$this->setUpSchema($this->em);
}
开发者ID:epoplive,项目名称:EasyBib_DoctrineTypes,代码行数:29,代码来源:HstoreTestCase.php
注:本文中的Doctrine\ORM\Tools\Setup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论