本文整理汇总了PHP中Doctrine\ORM\Tools\Setup::createXMLMetadataConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP Setup::createXMLMetadataConfiguration方法的具体用法?PHP Setup::createXMLMetadataConfiguration怎么用?PHP Setup::createXMLMetadataConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Tools\Setup
的用法示例。
在下文中一共展示了Setup::createXMLMetadataConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildProdConfig
public function buildProdConfig()
{
$proxies = dirname(__FILE__) . DS . 'proxies';
$config = Setup::createXMLMetadataConfiguration($this->paths, false, $proxies);
$config->setProxyNamespace('Infrastructure\\Persistence\\Doctrine\\Proxies');
return $config;
}
示例2: buildByConnection
/**
* Builds a container for a connection.
*
* @param mixed $connection Doctrine::DBAL connection
* @return DoctrineBackendContainer
*/
public static function buildByConnection($connection, $isDevMode = false)
{
$mappings = self::getXMLMappings();
$config = Setup::createXMLMetadataConfiguration($mappings, $isDevMode);
$entityManager = EntityManager::create($connection, $config);
return new self($entityManager);
}
示例3: __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);
}
示例4: setUp
protected function setUp()
{
$this->conn = $this->getSqliteConnection();
$this->config = Setup::createXMLMetadataConfiguration(array(__DIR__ . '/_files'), true);
$this->entityManager = EntityManager::create($this->conn, $this->config);
$this->ormProvider = new OrmSchemaProvider($this->entityManager);
}
示例5: 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);
}
示例6: 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;
}
}
示例7: setUp
protected function setUp()
{
$config = Setup::createXMLMetadataConfiguration([__DIR__ . '/../src/Resources/doctrine'], true);
$this->em = EntityManager::create(['driver' => 'pdo_sqlite', 'memory' => true], $config);
$tool = new SchemaTool($this->em);
$tool->createSchema($this->em->getMetadataFactory()->getAllMetadata());
$this->repo = $this->em->getRepository(SimpleArticle::class);
}
示例8: getEntityManager
private function getEntityManager()
{
$paths = array(Conf::getRootDir() . Conf::getDcotrineMappingsPath());
$isDevMode = true;
// the connection configuration
$dbParams = array('driver' => Conf::getDBDriver(), 'user' => Conf::getDBUser(), 'password' => Conf::getDBPassword(), 'dbname' => Conf::getDBName(), 'host' => Conf::getDBHost(), 'port' => Conf::getDBPort());
$configDoctrine = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
return EntityManager::create($dbParams, $configDoctrine);
}
示例9: register
/**
* Register the binding
*
* @return void
*/
public function register()
{
\App::singleton('Doctrine\\ORM\\EntityManager', function () {
$isDevMode = true;
$paths = array(__DIR__ . '/Infrastructure/Repository/Metadata');
$config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
$conn = array('driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'laravelddd', 'user' => 'root', 'password' => 'root');
return \Doctrine\ORM\EntityManager::create($conn, $config);
});
}
示例10: getEntityManager
protected function getEntityManager(array $metadata)
{
if (!$this->entityManager) {
$config = Setup::createXMLMetadataConfiguration($metadata, true, TESTS_DOCTRINE_PROXY_DIR);
//$conn = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/db/test.db');
$conn = array('driver' => 'pdo_sqlite', 'memory' => true);
$this->entityManager = EntityManager::create($conn, $config);
}
return $this->entityManager;
}
示例11: establishConnection
/**
* Establish a connection to the database using the following.
* @param array $connectionParams An array of parameters that establishes a connection.
* @return self
*/
public function establishConnection(array $connectionParams)
{
$paths = [__DIR__ . '/ORM/Config'];
$isDevMode = false;
$config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
$this->entityManager = EntityManager::create($connectionParams, $config);
$this->quizzes = $this->entityManager->getRepository('Quizzes\\Quiz');
$this->questions = $this->entityManager->getRepository('Quizzes\\Question');
$this->answers = $this->entityManager->getRepository('Quizzes\\Answer');
return $this;
}
示例12: getDB
protected static function getDB()
{
if (!self::$entityManager) {
$dbConfig = Config::getInstance()->getValues('db');
$db = array('driver' => 'pdo_mysql', 'host' => $dbConfig->DB_HOST . ':' . $dbConfig->DB_PORT, 'user' => $dbConfig->DB_USER, 'password' => $dbConfig->DB_PASS, 'dbname' => $dbConfig->DB_NAME);
$doctrineConfig = Setup::createXMLMetadataConfiguration(array(DIR_CACHE . '/doctrine'), $dbConfig->DB_DEV);
self::$entityManager = EntityManager::create($db, $doctrineConfig);
self::$entityManager->getConnection()->connect();
}
return self::$entityManager;
}
示例13: getEm
/**
* @return EntityManager
*/
public static function getEm($dbParams = array())
{
if (is_null(self::$em)) {
$paths[] = dirname(__DIR__) . '/resources/config/xml';
$isDevMode = false;
// the connection configuration
$dbParams += array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'foo');
$config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
self::$em = EntityManager::create($dbParams, $config);
}
return self::$em;
}
示例14: createConfiguration
/**
* Create Doctrine configuration.
*
* @param array $options
*
* @return \Doctrine\ORM\Configuration|null
*/
protected static function createConfiguration(array $options)
{
if ($options['annotation_paths']) {
return Setup::createAnnotationMetadataConfiguration(static::normalizePaths($options['annotation_paths']), false, $options['proxy_path'], $options['cache_driver'], false);
}
if ($options['xml_paths']) {
return Setup::createXMLMetadataConfiguration(static::normalizePaths($options['xml_paths']), false, $options['proxy_path'], $options['cache_driver']);
}
if ($options['yaml_paths']) {
return Setup::createYAMLMetadataConfiguration(static::normalizePaths($options['yaml_paths']), false, $options['proxy_path'], $options['cache_driver']);
}
return null;
}
示例15: register
/**
* Register Doctrine's entity manager
*
* @param Container $container
*/
public function register(Container $container)
{
$container['doctrine.em'] = function () use($container) {
$configuration = Setup::createXMLMetadataConfiguration($container['doctrine']['mapping_dirs'], $container['doctrine']['dev_mode'], $container['doctrine']['proxy_dir']);
$entityManager = EntityManager::create($container['doctrine']['connection'], $configuration);
$platform = $entityManager->getConnection()->getDatabasePlatform();
foreach ($container['doctrine']['types'] as $type => $class) {
!Type::hasType($type) && Type::addType($type, $class);
$platform->registerDoctrineTypeMapping($type, $type);
}
return $entityManager;
};
}