本文整理汇总了PHP中Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP Setup::createYAMLMetadataConfiguration方法的具体用法?PHP Setup::createYAMLMetadataConfiguration怎么用?PHP Setup::createYAMLMetadataConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Tools\Setup
的用法示例。
在下文中一共展示了Setup::createYAMLMetadataConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
protected function __construct()
{
self::register_autoload();
$connection_parameters = $this->get_connection_parameters();
$this->config = Setup::createYAMLMetadataConfiguration(array($this->get_entity_path() . '/mapping'), true);
$this->em = EntityManager::create($connection_parameters, $this->config);
}
示例2: __construct
/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct()
{
$paths = [__DIR__ . '/../../config'];
$databaseConfig = ['driver' => 'pdo_sqlite', 'path' => __DIR__ . '/../../db.sqlite'];
$config = Setup::createYAMLMetadataConfiguration($paths, true);
$this->entityManager = EntityManager::create($databaseConfig, $config);
}
示例3: 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);
}
示例4: setUpEntityManager
protected function setUpEntityManager($transformer = null)
{
$evm = new EventManager();
$evm->addEventSubscriber($this->getSubscriber($transformer));
$configuration = Setup::createYAMLMetadataConfiguration([__DIR__ . '/Fixture']);
$this->em = $this->getMockSqliteEntityManager($evm, $configuration);
}
示例5: createEntityManager
/**
* Create an EntityManager
*
* @return EntityManger
*/
public static function createEntityManager()
{
$paths = [__DIR__ . '/yaml'];
$isDevMode = true;
$connectionConfig = ['driver' => 'pdo_sqlite', 'database' => ':memory:', 'prefix' => ''];
$config = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
return EntityManager::create($connectionConfig, $config);
}
示例6: connectMysql
/**
* Connects to the Redis node
*/
protected function connectMysql()
{
$dbParams = array('driver' => 'pdo_mysql', 'user' => 'blockchain', 'password' => 'blockchain', 'dbname' => 'blockchain', 'host' => 'multichain-mysql.docker');
$isDevMode = true;
$paths = array("./yml/");
$config = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
$this->em = EntityManager::create($dbParams, $config);
}
示例7: getEntityManager
public static function getEntityManager()
{
if (static::$entityManager !== null) {
return static::$entityManager;
}
$isDevMode = true;
$config = Setup::createYAMLMetadataConfiguration(array(realpath(__DIR__ . "/../db")), $isDevMode);
$arrConfig = parse_ini_file(__DIR__ . "/../config/voetbal.ini", true);
return static::$entityManager = EntityManager::create($arrConfig["database"], $config);
}
示例8: getEm
/**
* @return EntityManager
*/
public function getEm()
{
// Basic configuration
$isDev = true;
$config = ['driver' => 'pdo_mysql', 'host' => 'localhost', 'user' => 'dev', 'password' => 'dev', 'dbname' => 'doctrine_tutorial'];
// Paths to directories with entity metadata
$metadata_paths = [__DIR__ . '/../src/Customer/mapping', __DIR__ . '/../src/Menu/mapping', __DIR__ . '/../src/Product/mapping'];
$configuration = Setup::createYAMLMetadataConfiguration($metadata_paths, isset($isDev) ? $isDev : false);
return EntityManager::create($config, $configuration);
}
示例9: __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);
}
示例10: register
/**
* Use the register method to register items with the container via the
* protected $this->container property or the `getContainer` method
* from the ContainerAwareTrait.
*
* @return void
*/
public function register()
{
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__ . "/../../../config/orm/"), $this->container->get('isDevMode'));
$conn = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/../../../db.sqlite');
$this->entityManager = EntityManager::create($conn, $config);
if (!Type::hasType("task_description")) {
Type::addType('task_description', TaskDescription::class);
$this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('description', 'task_description');
}
$this->getContainer()->add('entityManager', $this->entityManager);
$this->getContainer()->add('JGimeno\\TaskReporter\\Entity\\WorkingDayRepositoryInterface', DoctrineWorkingDayRepository::class)->withArgument($this->entityManager);
}
示例11: GetEntityManager
function GetEntityManager()
{
$paths = [realpath(__DIR__ . '/yml/')];
$isDevMode = false;
// the connection configuration
$dbParams = ['driver' => 'pdo_sqlite', 'user' => 'root', 'password' => '', 'dbname' => 'foo', 'path' => ':memory:', 'memory' => 'true'];
// $config instanceof Doctrine\ORM\Configuration
$config = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
$namespaces = [__DIR__ . '/yml/' => 'NilPortugues\\Tests\\Api\\JsonApi\\Integrations\\Doctrine\\Entity'];
$driver = new SimplifiedYamlDriver($namespaces);
$config->setMetadataDriverImpl($driver);
//replace default driver
return EntityManager::create($dbParams, $config);
}
示例12: __construct
public function __construct()
{
$isDev = config('app.dev');
// Initialize template engine (Twig)
$loader = new \Twig_Loader_Filesystem(config('view.path'));
$this->twig = new \Twig_Environment($loader, ['debug' => $isDev, 'auto_reload' => $isDev, 'cache' => config('view.cache')]);
// Initialize FormFactory with extensions required for app
$this->formFactory = (new AppFormFactory($this->twig))->build();
// Get request data
$this->request = Request::createFromGlobals();
// Initialize Doctrine EntityManager
$config = Setup::createYAMLMetadataConfiguration([base_path("config/doctrine")], $isDev);
$config->setQueryCacheImpl(new ApcCache());
$config->setResultCacheImpl(new ApcCache());
$conn = config('database');
$this->em = EntityManager::create($conn, $config);
}
示例13: beforeTestMethod
public function beforeTestMethod($testMethod)
{
$this->mockGenerator->shuntParentClassCalls();
$this->mockGenerator->orphanize('__construct');
$pdo = new \mock\PDO();
$this->mockGenerator->orphanize('__construct');
$db = new \mock\Doctrine\DBAL\Connection();
$db->getMockController()->connect = function () {
};
$db->getMockController()->getEventManager = function () {
return new EventManager();
};
$db->getMockController()->getDatabasePlatform = function () {
return new MySqlPlatform();
};
$this->mockGenerator->unshuntParentClassCalls();
$config = Setup::createYAMLMetadataConfiguration([TEST_DATA_DIR . '/doctrine-orm'], true);
$this->connection = EntityManager::create($db, $config);
}
示例14: register
public function register(Application $app)
{
$config = json_decode(file_get_contents(__DIR__ . '/../../config/parameters.json'), true);
$conn = $config["orm.doctrine.db"];
$paths = $config["orm.doctrine.yml.paths"];
$debug = $config["debug"];
$app['debug'] = $debug;
$app['entity.manager'] = $app->share(function () use($conn, $paths, $debug) {
$config = Setup::createYAMLMetadataConfiguration($paths, $debug);
$config->addCustomNumericFunction('RANDOM', Random::class);
return EntityManager::create($conn, $config);
});
$app['word.selector'] = $app->share(function () use($app) {
$repository = $app['entity.manager']->getRepository(DoctrineWord::class);
return new StoredWordSelector($repository);
});
$app['word.controller'] = $app->share(function () use($app) {
return new WordController($app['word.selector']);
});
}
示例15: __construct
public function __construct()
{
require_once __DIR__ . '/Doctrine/ORM/Tools/Setup.php';
Setup::registerAutoloadDirectory(__DIR__);
// Load the database configuration from CodeIgniter
require APPPATH . 'config/database.php';
$connection_options = 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']));
// With this configuration, your model files need to be in application/models/Entity
// e.g. Creating a new Entity\User loads the class from application/models/Entity/User.php
$models_namespace = 'Entity';
$models_path = APPPATH . 'models';
$proxies_dir = APPPATH . 'models/Proxies';
$metadata_paths = array(APPPATH . 'models');
// Set $dev_mode to TRUE to disable caching while you develop
$dev_mode = true;
// If you want to use a different metadata driver, change createAnnotationMetadataConfiguration
// to createXMLMetadataConfiguration or createYAMLMetadataConfiguration.
$config = Setup::createYAMLMetadataConfiguration($metadata_paths, $dev_mode, $proxies_dir);
$this->em = EntityManager::create($connection_options, $config);
$loader = new ClassLoader($models_namespace, $models_path);
$loader->register();
}