本文整理汇总了PHP中Doctrine\Common\ClassLoader类的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader类的具体用法?PHP ClassLoader怎么用?PHP ClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClassLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/database.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$reader = new AnnotationReader();
$driverImpl = new AnnotationDriver($reader, array(APPPATH . "models/Entities"));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses(true);
AnnotationRegistry::registerLoader('class_exists');
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:richwandell,项目名称:Codeigniter-Example-App,代码行数:28,代码来源:Doctrine.php
示例2: initDoctrine
function initDoctrine()
{
require_once __DIR__ . '/../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
$classLoader = new ClassLoader('Doctrine\\ORM', realpath(__DIR__ . '/../lib'));
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\\DBAL', realpath(__DIR__ . '/../lib/vendor/doctrine-dbal/lib'));
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\\Common', realpath(__DIR__ . '/../lib/vendor/doctrine-common/lib'));
$classLoader->register();
$classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/../lib/vendor'));
$classLoader->register();
$classLoader = new ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new ClassLoader('Proxies', __DIR__);
$classLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ApcCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/Entities"));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
// Database connection information
$connectionOptions = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/database.sqlite');
// Create EntityManager
$em = EntityManager::create($connectionOptions, $config);
return $em;
}
开发者ID:holdensmagicalunicorn,项目名称:RunThisApp,代码行数:34,代码来源:index.php
示例3: __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
示例4: __construct
public function __construct()
{
// load database configuration from CodeIgniter
if (!file_exists($file_path = APPPATH . 'config/' . ENVIRONMENT . '/database.php') && !file_exists($file_path = APPPATH . 'config/database.php')) {
throw new Exception('The configuration file database.php does not exist.');
}
require $file_path;
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/Proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/Proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
$logger = new EchoSQLLogger();
$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(true);
// Database connection information
$connectionOptions = $this->convertDbConfig($db['default']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:ufhy,项目名称:codeigniter-doctrine,代码行数:31,代码来源:Doctrine.php
示例5: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/database.php';
//A Doctrine Autoloader is needed to load the models
$entitiesClassLoader = new ClassLoader('Entity', APPPATH . "models");
$entitiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
AnnotationRegistry::registerFile(APPPATH . "vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
$reader = new AnnotationReader();
$driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(APPPATH . 'models/Entity'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . 'models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
// $logger = new EchoSQLLogger;
// $config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => 'whoami', 'host' => 'localhost', 'dbname' => 'pms3');
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:rajuyohannan,项目名称:codeigniter-admin,代码行数:29,代码来源:Doctrine.php
示例6: __construct
public function __construct()
{
//Set up class loading. You cold use different autoloaders, provider by your
//if you want to.
require_once APPPATH . 'third_party/DoctrineORM-2.2.2/libraries/Doctrine/Common/ClassLoader.php';
require_once APPPATH . 'third_party/DoctrineORM-2.2.2/libraries/Doctrine/ORM/Tools/Setup.php';
Doctrine\ORM\Tools\Setup::registerAutoloadDirectory(APPPATH . 'third_party/DoctrineORM-2.2.2/libraries/');
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'third_party/DoctrineORM-2.2.2/libraries');
$doctrineClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
//Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver([APPPATH . 'models/Entities']);
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
//Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
//Set up logger
//$logger = new EchoSQLLogger;
//$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(true);
include APPPATH . 'config/database.php';
//Database connection information
$connectionOptions = ['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' => [1002 => 'SET NAMES utf8']];
//Enforce connection character set. This is very important if you are
//using MySQL and InnoDB tables!
//Doctrine_Manager::connection()->setCharset('utf8');
//Doctrine_Manager::connection()->setCollate('utf8_general_ci');
//Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:sk8sta13,项目名称:Clients,代码行数:35,代码来源:Doctrine.php
示例7: getDocumentManager
protected function getDocumentManager()
{
if (is_null($this->_documentManager)) {
$options = $this->getOptions();
// ODM Class
$classLoader = new ClassLoader('Doctrine\\ODM\\MongoDB', APPLICATION_PATH . '/../library');
$classLoader->register();
// Common Class
$classLoader = new ClassLoader('Doctrine\\Common', APPLICATION_PATH . '/../library');
$classLoader->register();
// MongoDB Class
$classLoader = new ClassLoader('Doctrine\\MongoDB', APPLICATION_PATH . '/../library');
$classLoader->register();
$classLoader = new ClassLoader('Documents', $options['documentPath']);
$classLoader->register();
$config = new Configuration();
$config->setProxyDir($options['proxyDir']);
$config->setProxyNamespace($options['proxyNamespace']);
$config->setHydratorDir($options['hydratorDir']);
$config->setHydratorNamespace($options['hydratorNamespace']);
$reader = new AnnotationReader();
AnnotationDriver::registerAnnotationClasses();
$config->setMetadataDriverImpl(new AnnotationDriver($reader, $options['documentPath']));
$config->setDefaultDB($options['dbname']);
$this->_documentManager = DocumentManager::create(new Connection($options['server']), $config);
}
return $this->_documentManager;
}
开发者ID:ud223,项目名称:yj,代码行数:28,代码来源:MongoDocumentManager.php
示例8: __construct
public function __construct(array $dbConfig, array $options = array())
{
extract($options);
$entityClassLoader = new ClassLoader("Entities", $entityPath);
$entityClassLoader->register();
$proxyPath = isset($proxyPath) ? $proxyPath : $entityPath;
$proxyClassLoader = new ClassLoader("Proxies", $proxyPath);
$proxyClassLoader->register();
$config = new Configuration();
if ($isDevMode || $isArrayCache) {
$cache = new ArrayCache();
} else {
$cache = new ApcCache();
}
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
$config->setProxyDir($proxyPath);
$config->setProxyNamespace($namespaces["proxy"]);
if (isset($isDevMode) && $isDevMode) {
$config->setAutogenerateProxyClasses(true);
}
if (isset($driverClass) && class_exists($driverClass)) {
$annotationDriver = new $driverClass($entity_driver);
} else {
$annotationDriver = new AnnotationDriver(new AnnotationReader(), array($entityPath));
AnnotationRegistry::registerLoader('class_exists');
}
$config->setMetadataDriverImpl($annotationDriver);
$this->setEntityManager($dbConfig, $config);
}
开发者ID:Luyanda86,项目名称:silex-playground,代码行数:30,代码来源:DoctrineService.php
示例9: __construct
/**
* constructor
*/
public function __construct()
{
// load database configuration from CodeIgniter
require APPPATH . 'config/database.php';
$doctrineClassLoader = new ClassLoader('Doctrine', FCPATH . 'vendors');
$doctrineClassLoader->register();
$symfonyClassLoader = new ClassLoader('Symfony', FCPATH . 'vendors/Doctrine');
$symfonyClassLoader->register();
$entityClassLoader = new ClassLoader('Entity', APPPATH . 'models');
$entityClassLoader->register();
$config = Doctrine\ORM\Tools\Setup::createConfiguration(ENVIRONMENT !== 'production');
$driverImpl = new AnnotationDriver(new AnnotationReader(), [APPPATH . 'models']);
AnnotationRegistry::registerLoader('class_exists');
$config->setMetadataDriverImpl($driverImpl);
// Proxy configuration
$config->setProxyDir(APPPATH . 'models/Proxies');
$config->setProxyNamespace('Proxies');
if (ENVIRONMENT === 'production') {
// Set up caches
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
} else {
// Set up logger
// $logger = new EchoSQLLogger;
// $config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
}
// Database connection information
$connectionOptions = array('driver' => $db[$active_group]['dbdriver'], 'user' => $db[$active_group]['username'], 'password' => $db[$active_group]['password'], 'host' => $db[$active_group]['hostname'], 'port' => $db[$active_group]['port'], 'dbname' => $db[$active_group]['database'], 'charset' => $db[$active_group]['char_set'], 'collation' => $db[$active_group]['dbcollat']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:jeffdrumgod,项目名称:hapia,代码行数:36,代码来源:Doctrine.php
示例10: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/database.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
//require_once APPPATH.'libraries/Doctrine/Common/ClassLoader.php';
// We use the Composer Autoloader instead - just set
// $config['composer_autoload'] = TRUE; in application/config/config.php
//require_once APPPATH.'vendor/autoload.php';
//A Doctrine Autoloader is needed to load the models
$entitiesClassLoader = new ClassLoader('Entities', APPPATH . "models");
$entitiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
$logger = new EchoSQLLogger();
$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => 'dev_pila', 'password' => 'damienludothomas', 'host' => 'localhost', 'dbname' => 'tradr');
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:Thogusa,项目名称:Projet-Pila,代码行数:33,代码来源:Doctrine.php
示例11: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/development/database.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
require_once APPPATH . 'libraries/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
$logger = new EchoSQLLogger();
$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:ismael-rivera,项目名称:project-manati,代码行数:33,代码来源:Doctrine.php
示例12: __construct
public function __construct()
{
//cargamos la configuración de base de datos de codeigniter
require APPPATH . "config/database.php";
//utilizamos el namespace Entities para mapear el directorio models
$entitiesClassLoader = new ClassLoader('Entities', rtrim(APPPATH . "models"));
$entitiesClassLoader->register();
//utilizamos el namespace Proxies para mapear el directorio models/proxies
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Configuración y chaché
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Configuración Proxy
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
// Habilitar el logger para obtener información de cada proceso
$logger = new EchoSQLLogger();
//$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
//configuramos la conexión con la base de datos utilizando las credenciales de nuestra app
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db["default"]["username"], 'password' => $db["default"]["password"], 'host' => $db["default"]["hostname"], 'dbname' => $db["default"]["database"]);
// Creamos el EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
开发者ID:uno-de-piera,项目名称:doctrine-codeigniter3,代码行数:30,代码来源:Doctrine.php
示例13: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH.'config/database.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
require_once APPPATH.'libraries/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH.'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, '/'));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH.'models/proxies');
$proxiesClassLoader->register();
//extension
$extensionClassLoader = new ClassLoader('DoctrineExtensions', APPPATH.'libraries/DoctrineExtensions/lib');
$extensionClassLoader->register();
// Set up caches
$config = new Configuration;
// Caching Configuration (5)
//if (APPLICATION_ENV == "development") {
$cache = new \Doctrine\Common\Cache\ArrayCache();
//} else {
// $cache = new \Doctrine\Common\Cache\ApcCache();
//}
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Set up driver
$Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
$Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, APPPATH.'models');
$config->setMetadataDriverImpl($driver);
// Proxy configuration
$config->setProxyDir(APPPATH.'/models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
//$logger = new EchoSqlLogger;
//$config->setSqlLogger($logger);
$config->setAutoGenerateProxyClasses( TRUE );
// Database connection information
$connectionOptions = array(
'driver' => 'pdo_mysql',
'user' => $db['default']['username'],
'password' => $db['default']['password'],
'host' => $db['default']['hostname'],
'dbname' => $db['default']['database']
);
//$evm = new Doctrine\Common\EventManager();
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);//, $evm);
}
开发者ID:nicnocquee,项目名称:PPION-Website,代码行数:59,代码来源:Doctrine.php
示例14: testClassLoaderCheckFileExists
public function testClassLoaderCheckFileExists()
{
$classLoader = new \Doctrine\Common\ClassLoader();
$classLoader->setBasePath('ClassLoaderTest', __DIR__);
$classLoader->setCheckFileExists(true);
// This would return a fatal error without check file exists true
$this->assertEquals($classLoader->loadClass('SomeInvalidClass'), false);
}
开发者ID:jackbravo,项目名称:doctrine,代码行数:8,代码来源:ClassLoaderTest.php
示例15: testGetClassLoader
public function testGetClassLoader()
{
$cl = new ClassLoader('ClassLoaderTest', __DIR__);
$cl->register();
$this->assertTrue(ClassLoader::getClassLoader('ClassLoaderTest\\ClassD') instanceof \Doctrine\Common\ClassLoader);
$this->assertNull(ClassLoader::getClassLoader('This\\Class\\Does\\Not\\Exist'));
$cl->unregister();
}
开发者ID:GMBN,项目名称:ZF2---DoctrineModule---ManyToOne-,代码行数:8,代码来源:ClassLoaderTest.php
示例16: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require APPPATH . 'config/database.php';
//A Doctrine Autoloader is needed to load the models
// first argument of classloader is namespace and second argument is path
// setup models/entity namespace
$entityLoader = new ClassLoader('models', APPPATH);
$entityLoader->register();
foreach (glob(APPPATH . 'modules/*', GLOB_ONLYDIR) as $m) {
$module = str_replace(APPPATH . 'modules/', '', $m);
$entityLoader = new ClassLoader($module, APPPATH . 'modules');
$entityLoader->register();
}
//Register proxies namespace
$proxyLoader = new ClassLoader('Proxies', APPPATH . 'Proxies');
$proxyLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
// Set up entity
$reader = new AnnotationReader($cache);
$models = array(APPPATH . 'models');
foreach (glob(APPPATH . 'modules/*/models', GLOB_ONLYDIR) as $m) {
array_push($models, $m);
}
$driver = new AnnotationDriver($reader, $models);
$config->setMetadataDriverImpl($driver);
// Setup Gedmo
$cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader($reader, $cache);
// create a driver chain for metadata reading
$driverChain = new Doctrine\ORM\Mapping\Driver\DriverChain();
// load superclass metadata mapping only, into driver chain
// also registers Gedmo annotations.NOTE: you can personalize it
Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $cachedAnnotationReader);
$event = new EventManager();
$timestampableListener = new TimestampableListener();
$timestampableListener->setAnnotationReader($cachedAnnotationReader);
$event->addEventSubscriber($timestampableListener);
$slugListener = new SluggableListener();
$slugListener->setAnnotationReader($cachedAnnotationReader);
$event->addEventSubscriber($slugListener);
// Proxy configuration
$config->setProxyDir(APPPATH . '/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
// $logger = new EchoSQLLogger;
// $config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config, $event);
}
开发者ID:santhapa,项目名称:ci-mag-cms,代码行数:58,代码来源:Doctrine.php
示例17: __construct
public function __construct()
{
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
$directory = APPPATH . "third_party/doctrine2-orm";
if (!class_exists('Doctrine\\ORM\\Tools\\Setup', false)) {
require $directory . '/Doctrine/ORM/Tools/Setup.php';
}
Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($directory);
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
$doctrineClassLoader->register();
// Set up models loading
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
$entitiesClassLoader->register();
foreach (glob(APPPATH . 'modules/*', GLOB_ONLYDIR) as $m) {
$module = str_replace(APPPATH . 'modules/', '', $m);
$loader = new ClassLoader($module, APPPATH . 'modules');
$loader->register();
}
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Set up caches
$this->config = new Configuration();
$cache = new ArrayCache();
// $cache = new \Doctrine\Common\Cache\ApcCache;
$this->config->setMetadataCacheImpl($cache);
$this->config->setQueryCacheImpl($cache);
// Set up models
$models = array(APPPATH . 'models');
foreach (glob(APPPATH . 'modules/*/models', GLOB_ONLYDIR) as $m) {
array_push($models, $m);
}
$driverImpl = $this->config->newDefaultAnnotationDriver($models);
$this->config->setMetadataDriverImpl($driverImpl);
// Proxy configuration
$this->config->setProxyDir(APPPATH . '/models/proxies');
$this->config->setProxyNamespace('Proxies');
// Set up logger
// $logger = new EchoSQLLogger;
// $this->config->setSQLLogger($logger);
$this->config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
// load database configuration from CodeIgniter
// Is the config file in the environment folder?
if (!defined('ENVIRONMENT') or !file_exists($file_path = APPPATH . 'config/' . ENVIRONMENT . '/database.php')) {
if (!file_exists($file_path = APPPATH . 'config/database.php')) {
show_error('The configuration file database.php does not exist.');
}
}
include $file_path;
if (!isset($db) or count($db) == 0) {
show_error('No database connection settings were found in the database config file.');
}
$this->connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
// Create EntityManager
$this->em = EntityManager::create($this->connectionOptions, $this->config);
}
开发者ID:NaszvadiG,项目名称:ci-beam,代码行数:57,代码来源:Doctrine.php
示例18: __construct
public function __construct()
{
// Is the config file in the environment folder?
if (!defined('ENVIRONMENT') or !file_exists($file_path = APPPATH . 'config/' . ENVIRONMENT . '/database.php')) {
$file_path = APPPATH . 'config/database.php';
}
// load database configuration from CodeIgniter
require $file_path;
// Set up class loading
require_once APPPATH . 'third_party/doctrine-orm/Doctrine/Common/ClassLoader.php';
$loader = new ClassLoader('Doctrine', APPPATH . 'third_party/doctrine-orm');
$loader->register();
// Set up models loading
$loader = new ClassLoader('models', APPPATH);
$loader->register();
foreach (glob(APPPATH . 'modules/*', GLOB_ONLYDIR) as $m) {
$module = str_replace(APPPATH . 'modules/', '', $m);
$loader = new ClassLoader($module, APPPATH . 'modules');
$loader->register();
}
// Set up proxies loading
$loader = new ClassLoader('Proxies', APPPATH . 'Proxies');
$loader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Set up driver
$reader = new AnnotationReader($cache);
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
// Set up models
$models = array(APPPATH . 'models');
foreach (glob(APPPATH . 'modules/*/models', GLOB_ONLYDIR) as $m) {
array_push($models, $m);
}
$driver = new AnnotationDriver($reader, $models);
$config->setMetadataDriverImpl($driver);
// Proxy configuration
$config->setProxyDir(APPPATH . '/Proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
//$logger = new EchoSqlLogger;
//$config->setSqlLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connection = array('driver' => 'pdo_mysql', 'user' => $db[$active_group]['username'], 'password' => $db[$active_group]['password'], 'host' => $db[$active_group]['hostname'], 'dbname' => $db[$active_group]['database']);
// Create EntityManager
$this->em = EntityManager::create($connection, $config);
// Force UTF-8
$this->em->getEventManager()->addEventSubscriber(new MysqlSessionInit('utf8', 'utf8_unicode_ci'));
// Schema Tool
$this->tool = new SchemaTool($this->em);
//auto generate entities from database
//$this->generate_entities();
}
开发者ID:jgat2012,项目名称:hp_oms,代码行数:56,代码来源:Doctrine.php
示例19: registerAutoloadDirectory
/**
* Use this method to register all autoloads for a downloaded Doctrine library.
* Pick the directory the library was uncompressed into.
*
* @param string $directory
*
* @return void
*/
public static function registerAutoloadDirectory($directory)
{
if (!class_exists('Doctrine\\Common\\ClassLoader', false)) {
require_once $directory . "/Doctrine/Common/ClassLoader.php";
}
$loader = new ClassLoader("Doctrine", $directory);
$loader->register();
$loader = new ClassLoader("Symfony\\Component", $directory . "/Doctrine");
$loader->register();
}
开发者ID:karvannan-thi,项目名称:doctrine2,代码行数:18,代码来源:Setup.php
示例20: obterLoaders
private function obterLoaders($dados)
{
require_once LIB . DS . 'Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', LIB);
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('modelo', MODELO);
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader($dados['proxy_namespace'], RAIZ . DS . $dados['proxy_dir']);
$proxiesClassLoader->register();
}
开发者ID:jjaferson,项目名称:ourives,代码行数:10,代码来源:DoctrinePlugin.php
注:本文中的Doctrine\Common\ClassLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论