コード例 #1
0
 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);
 }
コード例 #2
0
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;
}
コード例 #3
0
ファイル: Doctrine.php プロジェクト: ndongalameck/ceafieUan
 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();
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: Doctrine.php プロジェクト: sk8sta13/Clients
 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);
 }
コード例 #7
0
ファイル: MongoDocumentManager.php プロジェクト: ud223/yj
 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;
 }
コード例 #8
0
 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);
 }
コード例 #9
0
ファイル: Doctrine.php プロジェクト: jeffdrumgod/hapia
 /**
  * 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);
 }
コード例 #10
0
ファイル: Doctrine.php プロジェクト: Thogusa/Projet-Pila
 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);
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 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);
 }
コード例 #13
0
ファイル: Doctrine.php プロジェクト: nicnocquee/PPION-Website
  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);
  }
コード例 #14
0
 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);
 }
コード例 #15
0
 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();
 }
コード例 #16
0
ファイル: Doctrine.php プロジェクト: santhapa/ci-mag-cms
 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);
 }
コード例 #17
0
ファイル: Doctrine.php プロジェクト: NaszvadiG/ci-beam
 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);
 }
コード例 #18
0
ファイル: Doctrine.php プロジェクト: jgat2012/hp_oms
 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();
 }
コード例 #19
0
ファイル: Setup.php プロジェクト: karvannan-thi/doctrine2
 /**
  * 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();
 }
コード例 #20
0
ファイル: DoctrinePlugin.php プロジェクト: jjaferson/ourives
 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();
 }
コード例 #21
0
ファイル: Doctrine.php プロジェクト: bardascat/blogify
 public function Doctrine()
 {
     require_once APPPATH . 'libraries/vendor/autoload.php';
     $doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
     $doctrineClassLoader->register();
     $entitiesClassLoader = new ClassLoader('BusinessLogic', rtrim(APPPATH, "/"));
     $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', APPPATH . 'libraries');
     $classLoader->register();
     $entitiesClassLoader->register();
     $this->initDB();
 }
コード例 #22
0
ファイル: Bootstrap.php プロジェクト: BillTheBest/MetaNAS
 public function _initClassLoaders()
 {
     $loader = new ClassLoader('Doctrine\\ORM');
     $loader->register();
     $loader = new ClassLoader('Doctrine\\Common');
     $loader->register();
     $loader = new ClassLoader('Doctrine\\DBAL');
     $loader->register();
     $loader = new ClassLoader('Symfony', 'Doctrine');
     $loader->register();
     $loader = new ClassLoader('Entity', APPLICATION_PATH . '/models');
     $loader->register();
 }
コード例 #23
0
ファイル: doctrine.php プロジェクト: csiber/codeigniterplus
 /**
  * constructor
  */
 public function __construct()
 {
     // load database configuration from CodeIgniter
     require 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.'third_party/Doctrine/Common/ClassLoader.php';
     $doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . '../vendor/doctrine');
     $doctrineClassLoader->register();
     $entitiesClassLoader = new ClassLoader('models', APPPATH . "models/Entities");
     $entitiesClassLoader->register();
     $proxiesClassLoader = new ClassLoader('proxies', APPPATH . 'models/proxies');
     $proxiesClassLoader->register();
     // Set up caches
     $config = new Configuration();
     //TODO this approach won't work always, developers may habe memcached installed, but not interested
     //to use or server not running. Need to fix.
     if (class_exists('Memcached')) {
         $memcache = new \Memcached();
         $memcache->addServer('127.0.0.1', 11211);
         $cacheDriver = new \Doctrine\Common\Cache\MemcachedCache();
         $cacheDriver->setMemcached($memcache);
     } else {
         if (extension_loaded('apc') && ini_get('apc.enabled')) {
             $cacheDriver = new \Doctrine\Common\Cache\ApcCache();
         } else {
             $cacheDriver = new \Doctrine\Common\Cache\ArrayCache();
         }
     }
     $config->setMetadataCacheImpl($cacheDriver);
     $driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cacheDriver);
     // Proxy configuration
     $config->setProxyDir(APPPATH . 'models/proxies');
     $config->setProxyNamespace('Proxies');
     // Set up logger
     //$logger = new Doctrine\DBAL\Logging\CIProfiler();
     //$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);
     foreach ($driverImpl->getAllClassNames() as $class) {
         require_once $entitiesClassLoader->getIncludePath() . "/" . $class . ".php";
     }
     //$this->generate_classes();
 }
コード例 #24
0
ファイル: Bootstrap.php プロジェクト: jsuggs/BBM_old
 public function _initDoctrine()
 {
     $classLoader = new ClassLoader('Doctrine');
     $classLoader->register();
     $config = new Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setResultCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $driverImpl = $config->newDefaultAnnotationDriver('/home/jsuggs/bbm/BBM');
     $config->setMetadataDriverImpl($driverImpl);
     $config->setProxyDir(PROXYDIR);
     $config->setProxyNamespace('DoctrineProxies');
     $connectionOptions = array('driver' => 'pdo_pgsql', 'user' => 'bbm', 'password' => 'bbm', 'host' => 'localhost', 'dbname' => 'bbm');
     $em = EntityManager::create($connectionOptions, $config);
     return $em;
 }
コード例 #25
0
ファイル: manage_elementtypes.php プロジェクト: Jazzee/Jazzee
 /**
  * Create a new pagetype
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("manage/elementtypes/new"));
     $field = $form->newField();
     $field->setLegend('New element type');
     $element = $field->newElement('TextInput', 'name');
     $element->setLabel('Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\Safe($element));
     $element = $field->newElement('TextInput', 'class');
     $element->setLabel('Class');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Add Element');
     $this->setVar('form', $form);
     if ($input = $form->processInput($this->post)) {
         //class_exists causes doctrine to try and load the class which fails so we look first if doctrine can load it and then
         //if that fails we use class exists with no auto_load so it just looks in existing includes
         if (\Doctrine\Common\ClassLoader::classExists(ltrim($input->get('class'), '\\')) or class_exists($input->get('class'), false)) {
             $elementType = new \Jazzee\Entity\ElementType();
             $elementType->setName($input->get('name'));
             $elementType->setClass($input->get('class'));
             $this->addMessage('success', $input->get('name') . " saved.");
             $this->_em->persist($elementType);
             $this->redirectPath('manage/elementtypes');
         } else {
             $this->addMessage('error', "That is not a valid class name.  The class must eithier by loadable by a Doctrine::classLoader registered in the autoload stack or already be included.");
         }
     }
 }
コード例 #26
0
ファイル: Doctrine.php プロジェクト: ale-php/CI-skeleton
 public function __construct()
 {
     // 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
     $config = Setup::createAnnotationMetadataConfiguration($metadata_paths, $dev_mode = true, $proxies_dir);
     $this->em = EntityManager::create($connection_options, $config);
     $loader = new ClassLoader($models_namespace, $models_path);
     $loader->register();
 }
コード例 #27
0
ファイル: PartKeepr.php プロジェクト: JohnEffland/PartKeepr
 /**
  * Initializes the doctrine class loader and sets up the
  * directories.
  * 
  * @param none
  * @return nothing
  */
 public static function initializeClassLoaders()
 {
     require_once 'Doctrine/Common/ClassLoader.php';
     $classLoader = new ClassLoader('PartKeepr', self::getRootDirectory() . "/src/backend");
     $classLoader->register();
     $classLoader = new ClassLoader('Doctrine\\ORM');
     $classLoader->register();
     $classLoader = new ClassLoader("Doctrine\\DBAL\\Migrations", self::getRootDirectory() . "/3rdparty/doctrine-migrations/lib");
     $classLoader->register();
     $classLoader = new ClassLoader('Doctrine\\DBAL');
     $classLoader->register();
     $classLoader = new ClassLoader('Doctrine\\Common');
     $classLoader->register();
     $classLoader = new ClassLoader('Symfony');
     $classLoader->register();
     $classLoader = new ClassLoader("DoctrineExtensions\\NestedSet", self::getRootDirectory() . "/3rdparty/doctrine2-nestedset/lib");
     $classLoader->register();
 }
コード例 #28
0
 /**
  * Configura as bibliotecas externas
  */
 public function _initClassLoaders()
 {
     $oLoader = new ClassLoader('Doctrine\\ORM');
     $oLoader->register();
     $oLoader = new ClassLoader('Doctrine\\Common');
     $oLoader->register();
     $oLoader = new ClassLoader('Doctrine\\DBAL');
     $oLoader->register();
     $oLoader = new ClassLoader('Symfony', 'Doctrine');
     $oLoader->register();
     $oLoader = new ClassLoader('Entity', APPLICATION_PATH . '/default/models');
     $oLoader->register();
     $oLoader = new ClassLoader('Administrativo', APPLICATION_PATH . '/entidades');
     $oLoader->register();
     $oLoader = new ClassLoader('Geral', APPLICATION_PATH . '/entidades');
     $oLoader->register();
     $oLoader = new ClassLoader('Contribuinte', APPLICATION_PATH . '/entidades');
     $oLoader->register();
 }
コード例 #29
0
 public function __construct()
 {
     // load database configuration from CodeIgniter
     require_once __DIR__ . '/../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('TP', APPPATH . "models");
     $entitiesClassLoader->register();
     // Set up caches
     $config = new Configuration();
     if (ENVIRONMENT == 'development') {
         // set up simple array caching for development mode
         $cache = new \Doctrine\Common\Cache\ArrayCache();
     } else {
         // set up caching with APC for production mode
         $cache = new \Doctrine\Common\Cache\ApcCache();
     }
     $config->setMetadataCacheImpl($cache);
     $driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/TP'));
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     // Proxy configuration
     $config->setProxyDir(APPPATH . '/models/proxies');
     $config->setProxyNamespace('Proxies');
     // Sets up logger - uncomment following lines if you want to print the query for each data request from
     // Doctrine
     //		$logger = new EchoSQLLogger;
     //		$config->setSQLLogger($logger);
     $config->setAutoGenerateProxyClasses(TRUE);
     // Database connection information
     // The line 'charset' is very important to get the Uniccode string work properly
     // The variable $db is loaded from the configuration file database.php
     $connectionOptions = 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']);
     // Create EntityManager
     $this->em = EntityManager::create($connectionOptions, $config);
 }
コード例 #30
0
 public function testClassLoader()
 {
     $classLoader = new ClassLoader('ClassLoaderTest');
     $classLoader->setIncludePath(__DIR__);
     $classLoader->setFileExtension('.class.php');
     $classLoader->setNamespaceSeparator('_');
     $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassA'), true);
     $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassB'), true);
     $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassC'), true);
 }