当前位置: 首页>>代码示例>>PHP>>正文


PHP Tools\Setup类代码示例

本文整理汇总了PHP中Doctrine\ORM\Tools\Setup的典型用法代码示例。如果您正苦于以下问题:PHP Setup类的具体用法?PHP Setup怎么用?PHP Setup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Setup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     require APPPATH . 'config/database.php';
     $dbParams = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database'], 'charset' => $db['default']['char_set'], 'driverOptions' => array('charset' => $db['default']['char_set']));
     $isDevMode = true;
     $config = new Configuration();
     $setup = new Setup();
     $config = $setup->createAnnotationMetadataConfiguration(array(APPPATH . "models"), $isDevMode);
     $config = $setup->createYAMLMetadataConfiguration(array(APPPATH . "models/Yaml"), $isDevMode);
     $this->em = EntityManager::create($dbParams, $config);
 }
开发者ID:vinny-silveira,项目名称:codeigniter-doctrine-twig,代码行数:11,代码来源:Doctrine.php

示例2: getConfig

 public static function getConfig($appName, $modelNames = null)
 {
     $mappingDriver = new Tinebase_Record_DoctrineMappingDriver();
     if (!$modelNames) {
         $modelNames = array();
         foreach ($mappingDriver->getAllClassNames() as $modelName) {
             $modelConfig = $modelName::getConfiguration();
             if ($modelConfig->getApplName() == $appName) {
                 $modelNames[] = $modelName;
             }
         }
     }
     $tableNames = array();
     foreach ($modelNames as $modelName) {
         $modelConfig = $modelName::getConfiguration();
         if (!$mappingDriver->isTransient($modelName)) {
             throw new Setup_Exception('Model not yet doctrine2 ready');
         }
         $tableNames[] = SQL_TABLE_PREFIX . Tinebase_Helper::array_value('name', $modelConfig->getTable());
     }
     $config = Setup::createConfiguration();
     $config->setMetadataDriverImpl($mappingDriver);
     $config->setFilterSchemaAssetsExpression('/' . implode('|', $tableNames) . '/');
     return $config;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:25,代码来源:SchemaTool.php

示例3: setUp

 public function setUp()
 {
     $this->_oldEntityManager = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager();
     $this->_oldAuditedClassNames = \SoliantEntityAudit\Module::getModuleOptions()->getAuditedClassNames();
     $this->_oldJoinClasses = \SoliantEntityAudit\Module::getModuleOptions()->resetJoinClasses();
     $isDevMode = false;
     $config = Setup::createConfiguration($isDevMode, null, null);
     $chain = new DriverChain();
     // Use ZFC User for authentication tests
     $chain->addDriver(new XmlDriver(__DIR__ . '/../../../vendor/zf-commons/zfc-user-doctrine-orm/config/xml/zfcuser'), 'ZfcUser\\Entity');
     $chain->addDriver(new XmlDriver(__DIR__ . '/../../../vendor/zf-commons/zfc-user-doctrine-orm/config/xml/zfcuserdoctrineorm'), 'ZfcUserDoctrineORM\\Entity');
     $chain->addDriver(new StaticPHPDriver(__DIR__ . "/../Models"), 'SoliantEntityAuditTest\\Models\\LogRevision');
     $chain->addDriver(new AuditDriver('.'), 'SoliantEntityAudit\\Entity');
     $config->setMetadataDriverImpl($chain);
     // Replace entity manager
     $moduleOptions = \SoliantEntityAudit\Module::getModuleOptions();
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     $moduleOptions->setAuditedClassNames(array('SoliantEntityAuditTest\\Models\\LogRevision\\Album' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\Performer' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\Song' => array(), 'SoliantEntityAuditTest\\Models\\LogRevision\\SingleCoverArt' => array()));
     $entityManager = EntityManager::create($conn, $config);
     $moduleOptions->setEntityManager($entityManager);
     $schemaTool = new SchemaTool($entityManager);
     // Add auditing listener
     $entityManager->getEventManager()->addEventSubscriber(new LogRevision());
     $sql = $schemaTool->getUpdateSchemaSql($entityManager->getMetadataFactory()->getAllMetadata());
     #print_r($sql);die();
     $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
     $this->_em = $entityManager;
 }
开发者ID:VOONWerbeagentur,项目名称:SoliantEntityAudit,代码行数:28,代码来源:LogRevisionTest.php

示例4: __construct

 public function __construct(Configuration $configuration)
 {
     $driver = new PHPDriver(__DIR__ . '/../Mapping/');
     $config = Setup::createConfiguration($configuration['debug']);
     $config->setMetadataDriverImpl($driver);
     $this->entityManager = EntityManager::create($configuration['database']['write_connection'], $config);
 }
开发者ID:NigelGreenway,项目名称:Architectural-Playground,代码行数:7,代码来源:EntityManagerAdaptor.php

示例5: register

 public function register(Application $app)
 {
     $app['orm.em.paths'] = $app->share(function () {
         return array();
     });
     $app['orm.event_manager'] = $app->share(function () use($app) {
         return new EventManager();
     });
     $app['orm.config'] = $app->share(function () use($app) {
         return Setup::createConfiguration($app['debug']);
     });
     $app['orm.anotation_reader'] = $app->share(function () use($app) {
         $annotationReader = new AnnotationReader();
         $cache = $app['orm.config']->getMetadataCacheImpl();
         return new CachedReader($annotationReader, $cache);
     });
     $app['orm.default_anotation_driver'] = $app->share(function () use($app) {
         AnnotationRegistry::registerFile($app['vendor_dir'] . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
         return new AnnotationDriver($app['orm.anotation_reader'], $app['orm.em.paths']);
     });
     $app['orm.em'] = $app->share(function () use($app) {
         $annotationReader = $app['orm.anotation_reader'];
         $eventManager = $app['orm.event_manager'];
         $driverChain = new MappingDriverChain();
         $driverChain->setDefaultDriver($app['orm.default_anotation_driver']);
         DoctrineExtensions::registerMappingIntoDriverChainORM($driverChain, $annotationReader);
         $loggableListener = new LoggableListener();
         $loggableListener->setAnnotationReader($annotationReader);
         $loggableListener->setUsername('admin');
         $eventManager->addEventSubscriber($loggableListener);
         $config = $app['orm.config'];
         $config->setMetadataDriverImpl($driverChain);
         return EntityManager::create($app['db.default_options'], $config, $eventManager);
     });
 }
开发者ID:xesenix,项目名称:bdf2-library,代码行数:35,代码来源:ORMServiceProvider.php

示例6: register

 public function register(Application $app)
 {
     $paths = array(realpath($app['config']['doctrine']['paths']['entity']));
     $isDevMode = $app['config']['doctrine']['devMode'];
     $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false);
     $app['doctrine'] = EntityManager::create($app['config']['doctrine']['db'], $config);
 }
开发者ID:joeyrivera,项目名称:phpug-silex-intro,代码行数:7,代码来源:Doctrine.php

示例7: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     // The parameters in Doctrine 2 and ZF2 are slightly different.
     // Below is an example how we can reuse the db settings
     $doctrineDbConfig = (array) $config['db'];
     $doctrineDbConfig['driver'] = strtolower($doctrineDbConfig['driver']);
     if (!isset($doctrineDbConfig['dbname'])) {
         $doctrineDbConfig['dbname'] = $doctrineDbConfig['database'];
     }
     if (!isset($doctrineDbConfig['host'])) {
         $doctrineDbConfig['host'] = $doctrineDbConfig['hostname'];
     }
     if (!isset($doctrineDbConfig['user'])) {
         $doctrineDbConfig['user'] = $doctrineDbConfig['username'];
     }
     $doctrineConfig = Setup::createAnnotationMetadataConfiguration($config['doctrine']['entity_path'], true);
     $entityManager = DoctrineEntityManager::create($doctrineDbConfig, $doctrineConfig);
     if (isset($config['doctrine']['initializers'])) {
         $eventManager = $entityManager->getEventManager();
         foreach ($config['doctrine']['initializers'] as $initializer) {
             $eventClass = new DoctrineEvent(new $initializer(), $serviceLocator);
             $eventManager->addEventListener(\Doctrine\ORM\Events::postLoad, $eventClass);
         }
     }
     if ($serviceLocator->has('doctrine-profiler')) {
         $profiler = $serviceLocator->get('doctrine-profiler');
         $entityManager->getConfiguration()->setSQLLogger($profiler);
     }
     return $entityManager;
 }
开发者ID:gsokolowski,项目名称:learnzf2,代码行数:31,代码来源:EntityManager.php

示例8: getEntityManager

 /**
  * @return EntityManager
  */
 public function getEntityManager()
 {
     if (!$this->entityManager instanceof EntityManager) {
         $this->entityManager = EntityManager::create($this->getConfiguration()->get('database'), Setup::createAnnotationMetadataConfiguration([$this->rootPath . '/src/Classes/Entities/', __DIR__ . '/Domain/Entities/'], true));
     }
     return $this->entityManager;
 }
开发者ID:smichaelsen,项目名称:php-salad-bowl,代码行数:10,代码来源:Bowl.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dbName = $input->getArgument('dbname');
     $path = $input->getOption('path');
     $extensionKey = $input->getOption('extension-key');
     $connectionParams = array('dbname' => $dbName, 'user' => $input->getOption('user'), 'password' => $input->getOption('password'), 'host' => $input->getOption('host'), 'driver' => $input->getOption('driver'), 'port' => $input->getOption('port'));
     $config = Setup::createAnnotationMetadataConfiguration(array('.'), false);
     $em = EntityManager::create($connectionParams, $config);
     $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     if (is_null($extensionKey)) {
         $extensionKey = $dbName;
         if (self::DEFAULT_PATH != $path) {
             $extensionKey = array_pop(explode(DIRECTORY_SEPARATOR, $path));
         }
     }
     $exporter = new ExtbaseExporter($cmf);
     $exporter->setExtensionKey($extensionKey);
     $exporter->setPath($input->getOption('path'));
     self::mapDefaultInputOptions($exporter, $input);
     $output->writeln(sprintf('Exporting database schema "<info>%s</info>".', $dbName));
     $result = $exporter->exportJson();
     foreach ($exporter->getLogs() as $log) {
         $output->writeln($log);
     }
     return $result ? 0 : 1;
 }
开发者ID:edrush,项目名称:extbaser,代码行数:28,代码来源:ExportExtbaseCommand.php

示例10: __construct

 private function __construct()
 {
     $settings = Setup::getSettings();
     $config = \Doctrine\ORM\Tools\Setup::createXMLMetadataConfiguration([__DIR__ . '/../Mapper', 'Bh/Mapper'], $settings['DevMode']);
     $conn = array('driver' => 'pdo_mysql', 'user' => $settings['DbUser'], 'password' => $settings['DbPass'], 'dbname' => $settings['DbName']);
     self::$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
 }
开发者ID:uglybob,项目名称:bh.net,代码行数:7,代码来源:Mapper.php

示例11: __construct

 public function __construct($sm, $params = array())
 {
     $this->sm = $sm;
     $path = $sm->get('pegase.core.path');
     foreach ($params['entities_folders'] as $i => $f) {
         $params['entities_folders'][$i] = $path->get_path($f);
     }
     $this->db_params = $params['database'];
     $isDevMode = true;
     $config = Setup::createAnnotationMetadataConfiguration($params['entities_folders'], $isDevMode);
     $this->em = EntityManager::create($params['database'], $config);
     /*
       // on vérifie la validité des mappings
     
       $validator = new SchemaValidator($this->em);
       $errors = $validator->validateMapping();
     
       if(count($errors) > 0) {
         // Lots of errors!
         echo implode("\n\n", $errors);
       }
       else
         echo "Les mappings sont ok.\n";
     */
     $this->schema = new Schema($sm, $this);
     $this->database = new Database($sm, $this);
     $this->entity = new Entity($sm, $this);
 }
开发者ID:nativgames,项目名称:pegase-external-doctrine2-orm,代码行数:28,代码来源:DoctrineService.php

示例12: addEntityManager

 /**
  * This method is used to add an entity manager to the doctrine service.
  * @param $id string The id you would like to store with the entity manager.
  * @param ulfberht\module\doctrine\config $config The doctrine configuration for
  *        the entity manager.
  * @return void
  */
 public function addEntityManager($id, config $config)
 {
     $development = $config->develop ? true : false;
     $cache = $config->enableCache ? new ArrayCache() : null;
     //setup type of metadata reading
     switch ($config->type) {
         case 'annotation':
             $docConfig = Setup::createAnnotationMetadataConfiguration($config->paths, $development, null, $cache);
             break;
         case 'xml':
             $docConfig = Setup::createXMLMetadataConfiguration($config->paths, $development, null, $cache);
             break;
         case 'yaml':
             $docConfig = Setup::createYAMLMetadataConfiguration($config->paths, $development, null, $cache);
             break;
     }
     //setup caching
     if (!is_null($cache)) {
         $docConfig->setQueryCacheImpl($cache);
         $docConfig->setMetadataCacheImpl($cache);
     }
     //setup database connection
     $dbConnInfo = array('driver' => $config->database->driver, 'host' => $config->database->host, 'dbname' => $config->database->name, 'user' => $config->database->user, 'password' => $config->database->password);
     //store entity manager
     $this->_doctrineEntityMangers[$id] = EntityManager::create($dbConnInfo, $docConfig);
 }
开发者ID:ua1-labs,项目名称:ulfberht-application,代码行数:33,代码来源:doctrine.php

示例13: __construct

 public function __construct()
 {
     $this->setRoot("/var/www/html/uan/");
     $this->setEntidade(array($this->getRoot() . "models/"));
     $this->setIsDevMode(true);
     $mode = "DESENVOLVIMENTO";
     $config = Setup::createAnnotationMetadataConfiguration($this->getEntidade(), $this->getIsDevMode(), NULL, NULL, FALSE);
     if ($mode == "DESENVOLVIMENTO") {
         $cache = new \Doctrine\Common\Cache\ArrayCache();
     } else {
         $cache = new \Doctrine\Common\Cache\ApcCache();
     }
     $config = new Configuration();
     $config->setMetadataCacheImpl($cache);
     $driverImpl = $config->newDefaultAnnotationDriver($this->getRoot() . 'models/');
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir($this->getRoot() . 'proxies/');
     $config->setProxyNamespace('proxies');
     if ($mode == "DESENVOLVIMENTO") {
         $config->setAutoGenerateProxyClasses(true);
     } else {
         $config->setAutoGenerateProxyClasses(false);
     }
     $config = Setup::createAnnotationMetadataConfiguration($this->getEntidade(), $this->getIsDevMode(), NULL, NULL, FALSE);
     $dbParams = array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'ceafie', 'charset' => 'utf8', 'driverOptions' => array(1002 => 'SET NAMES utf8'));
     $this->em = EntityManager::create($dbParams, $config);
     $loader = new ClassLoader('Entity', __DIR__ . '/models');
     $loader->register();
 }
开发者ID:ndongalameck,项目名称:ceafieUan,代码行数:30,代码来源:Doctrine.php

示例14: __construct

 public function __construct()
 {
     $yamlParser = new Parser();
     $dbParams = $yamlParser->parse(file_get_contents(__DIR__ . '/parameters.yml'));
     $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . '/../Entity'), true);
     $this->em = EntityManager::create($dbParams['database'], $config);
 }
开发者ID:karolbisztyga,项目名称:websockets,代码行数:7,代码来源:cli-config.php

示例15: __construct

 /**
  * @param array $database
  * @throws \Exception
  */
 public function __construct($database = [])
 {
     $this->db = $database;
     foreach ($this->db as $key => $db) {
         $this->allDb[$key] = function () use($db) {
             $db['dev'] = isset($db['dev']) && $db['dev'] ? true : false;
             if (isset($db['db_url'])) {
                 $dbParams = array('url' => $db['db_url']);
             } else {
                 if (!isset($db['driver']) || !isset($db['user']) || !isset($db['pass']) || !isset($db['host']) || !isset($db['db'])) {
                     throw new \Exception('Missing arguments for doctrine constructor');
                 }
                 $dbParams = array('driver' => $this->getDriver($db['driver']), 'user' => $db['user'], 'password' => $db['pass'], 'host' => $db['host'], 'dbname' => $db['db'], 'charset' => isset($db['charset']) ? $db['charset'] : 'utf8');
             }
             $evm = new EventManager();
             if (isset($db['prefix'])) {
                 $tablePrefix = new TablePrefix($db['prefix']);
                 $evm->addEventListener(Events::loadClassMetadata, $tablePrefix);
             }
             $config = Setup::createAnnotationMetadataConfiguration($db['path'], $db['dev']);
             if (!$db['dev']) {
                 $config->setQueryCacheImpl($db['cache']);
                 $config->setResultCacheImpl($db['cache']);
                 $config->setMetadataCacheImpl($db['cache']);
             }
             if (isset($db['functions']) && !empty($db['functions'])) {
                 $config->setCustomDatetimeFunctions($db['functions']['customDatetimeFunctions']);
                 $config->setCustomNumericFunctions($db['functions']['customNumericFunctions']);
                 $config->setCustomStringFunctions($db['functions']['customStringFunctions']);
             }
             return EntityManager::create($dbParams, $config, $evm);
         };
     }
 }
开发者ID:jetfirephp,项目名称:db,代码行数:38,代码来源:DoctrineConstructor.php


注:本文中的Doctrine\ORM\Tools\Setup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。