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


PHP ORM\Configuration类代码示例

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


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

示例1: addEntityNamespaces

 /**
  * @param OrmConfiguration $configuration
  */
 public function addEntityNamespaces(OrmConfiguration $configuration)
 {
     $this->knownNamespaceAlias = array_merge($this->knownNamespaceAlias, $configuration->getEntityNamespaces());
     if ($configuration->getMetadataDriverImpl()) {
         $this->entityClassnames = array_merge($this->entityClassnames, $configuration->getMetadataDriverImpl()->getAllClassNames());
     }
 }
开发者ID:zquintana,项目名称:SolrBundle,代码行数:10,代码来源:KnownNamespaceAliases.php

示例2: getEntityManager

 /**
  * Get entity manager.
  *
  * @return EntityManagerInterface
  */
 protected function getEntityManager()
 {
     if (null === $this->entityManager) {
         $params = ['driver' => 'pdo_sqlite', 'memory' => true];
         $cache = new ArrayCache();
         /** @var AnnotationReader $reader */
         $reader = new CachedReader(new AnnotationReader(), $cache);
         $annotationDriver = new AnnotationDriver($reader, [__DIR__ . '/../../../src/ORM']);
         $driverChain = new MappingDriverChain();
         $driverChain->addDriver($annotationDriver, Commander::ENTITY_NAMESPACE);
         DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $reader);
         $config = new Configuration();
         $config->setAutoGenerateProxyClasses(true);
         $config->setProxyDir(sys_get_temp_dir());
         $config->setProxyNamespace(Commander::ENTITY_NAMESPACE);
         $config->setMetadataDriverImpl($driverChain);
         $config->setMetadataCacheImpl($cache);
         $config->setQueryCacheImpl($cache);
         $config->setResultCacheImpl($cache);
         $config->setHydrationCacheImpl($cache);
         $timestampableListener = new TimestampableListener();
         $timestampableListener->setAnnotationReader($annotationDriver->getReader());
         $eventManager = new EventManager();
         $eventManager->addEventSubscriber($timestampableListener);
         $entityManager = EntityManager::create($params, $config, $eventManager);
         $schemaTool = new SchemaTool($entityManager);
         $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
         $this->entityManager = $entityManager;
     }
     return $this->entityManager;
 }
开发者ID:gravitymedia,项目名称:commander,代码行数:36,代码来源:TaskEntityRepositoryTest.php

示例3: getConfiguration

 /**
  * getEntityManagerOptions
  *
  * Return the Doctrine ORM configuration instance 
  * 
  * @param array $options The options array
  * @return Doctrine\ORM\Configuration
  */
 protected function getConfiguration()
 {
     if (!isset($this->_config)) {
         $options = $this->getOptions();
         $config = new Configuration();
         $config->setProxyDir($options['proxydir']);
         if (APPLICATION_ENV == 'development') {
             $options['autogenerateproxies'] = true;
             $options['cache'] = 'array';
         }
         if (isset($options['cache'])) {
             $cache = $this->createCache($options['cache']);
             $config->setMetadataCacheImpl($cache);
             $config->setQueryCacheImpl($cache);
         }
         if (isset($options['proxynamespace'])) {
             $config->setProxyNamespace($options['proxynamespace']);
         }
         $config->setAutoGenerateProxyClasses(false);
         if (isset($options['autogenerateproxies']) && $options['autogenerateproxies']) {
             $config->setAutoGenerateProxyClasses(true);
         }
         $config->setMetadataDriverImpl($this->createMetadataDriver($options['metadatadriver'], $options['entitydir']));
         $this->_config = $config;
     }
     return $this->_config;
 }
开发者ID:alex-patterson-webdev,项目名称:multiverse,代码行数:35,代码来源:Entitymanager.php

示例4: init

 public function init()
 {
     $dbParams = ['driver' => $this->driver, 'host' => $this->host, 'user' => $this->user, 'password' => $this->password, 'dbname' => $this->dbname, 'charset' => 'utf8mb4'];
     $this->pathProxy = $this->path . DIRECTORY_SEPARATOR . 'proxy';
     if (!is_dir($this->pathCache)) {
         File::createDirectory($this->pathCache);
     }
     if (!is_dir($this->pathProxy)) {
         File::createDirectory($this->pathProxy);
     }
     $config = new Configuration();
     $cache = new \Doctrine\Common\Cache\FilesystemCache($this->pathCache);
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $driverImpl = $config->newDefaultAnnotationDriver($this->path);
     $config->setMetadataDriverImpl($driverImpl);
     $config->setProxyDir($this->pathProxy);
     $config->setProxyNamespace('app\\tables\\proxy');
     if ($this->applicationMode == "development") {
         $config->setAutoGenerateProxyClasses(true);
     } else {
         $config->setAutoGenerateProxyClasses(false);
     }
     $this->doctrine = EntityManager::create($dbParams, $config);
 }
开发者ID:visionp,项目名称:TestFramework,代码行数:25,代码来源:Doctrine.php

示例5: prepareMocks

 /**
  * @return array
  */
 protected function prepareMocks()
 {
     $configuration = new Configuration();
     $configuration->addEntityNamespace('Stub', 'Oro\\Bundle\\BatchBundle\\Tests\\Unit\\ORM\\Query\\Stub');
     $classMetadata = new ClassMetadata('Entity');
     $classMetadata->mapField(['fieldName' => 'a', 'columnName' => 'a']);
     $classMetadata->mapField(['fieldName' => 'b', 'columnName' => 'b']);
     $classMetadata->setIdentifier(['a']);
     $platform = $this->getMockBuilder('Doctrine\\DBAL\\Platforms\\AbstractPlatform')->setMethods([])->disableOriginalConstructor()->getMockForAbstractClass();
     $statement = $this->getMockBuilder('Doctrine\\DBAL\\Statement')->setMethods(['fetch', 'fetchColumn', 'closeCursor'])->disableOriginalConstructor()->getMock();
     $driverConnection = $this->getMockBuilder('Doctrine\\DBAL\\Driver\\Connection')->setMethods(['query'])->disableOriginalConstructor()->getMockForAbstractClass();
     $driverConnection->expects($this->any())->method('query')->will($this->returnValue($statement));
     $driver = $this->getMockBuilder('Doctrine\\DBAL\\Driver')->setMethods(['connect', 'getDatabasePlatform'])->disableOriginalConstructor()->getMockForAbstractClass();
     $driver->expects($this->any())->method('connect')->will($this->returnValue($driverConnection));
     $driver->expects($this->any())->method('getDatabasePlatform')->will($this->returnValue($platform));
     $connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->setMethods(['getDatabasePlatform', 'executeQuery'])->setConstructorArgs([[], $driver])->getMock();
     $connection->expects($this->any())->method('getDatabasePlatform')->will($this->returnValue($platform));
     /** @var UnitOfWork $unitOfWork */
     $unitOfWork = $this->getMockBuilder('UnitOfWork')->setMethods(['getEntityPersister'])->disableOriginalConstructor()->getMock();
     $entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->setMethods(['getConfiguration', 'getClassMetadata', 'getConnection', 'getUnitOfWork'])->disableOriginalConstructor()->getMock();
     $entityManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration));
     $entityManager->expects($this->any())->method('getClassMetadata')->will($this->returnValue($classMetadata));
     $entityManager->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $entityManager->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($unitOfWork));
     return [$entityManager, $connection, $statement];
 }
开发者ID:northdakota,项目名称:platform,代码行数:29,代码来源:QueryCountCalculatorTest.php

示例6: setUp

 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->configuration = $this->getMock('Doctrine\\ORM\\Configuration');
     $this->entityManager = $this->createEntityManager();
     $this->repositoryFactory = new DefaultRepositoryFactory();
     $this->configuration->expects($this->any())->method('getDefaultRepositoryClassName')->will($this->returnValue('Doctrine\\Tests\\Models\\DDC869\\DDC869PaymentRepository'));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:10,代码来源:DefaultRepositoryFactoryTest.php

示例7: __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 . 'vendor/autoload.php';
     $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' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
     // Create EntityManager
     $this->em = EntityManager::create($connectionOptions, $config);
 }
开发者ID:NeroJz,项目名称:ci_doctrine,代码行数:29,代码来源:Doctrine.php

示例8: __invoke

 /**
  * @param  ContainerInterface $container
  * @return EntityManager
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     if (!isset($config['doctrine'])) {
         throw new ServiceNotCreatedException('Missing Doctrine configuration');
     }
     $config = $config['doctrine'];
     $proxyDir = isset($config['proxy_dir']) ? $config['proxy_dir'] : 'data/DoctrineORM/Proxy';
     $proxyNamespace = isset($config['proxy_namespace']) ? $config['proxy_namespace'] : 'DoctrineORM/Proxy';
     $autoGenerateProxyClasses = isset($config['configuration']['auto_generate_proxy_classes']) ? $config['configuration']['auto_generate_proxy_classes'] : false;
     $underscoreNamingStrategy = isset($config['configuration']['underscore_naming_strategy']) ? $config['configuration']['underscore_naming_strategy'] : false;
     // Doctrine ORM
     $doctrine = new Configuration();
     $doctrine->setProxyDir($proxyDir);
     $doctrine->setProxyNamespace($proxyNamespace);
     $doctrine->setAutoGenerateProxyClasses($autoGenerateProxyClasses);
     // Naming Strategy
     if ($underscoreNamingStrategy) {
         $doctrine->setNamingStrategy(new UnderscoreNamingStrategy());
     }
     // ORM mapping by Annotation
     //AnnotationRegistry::registerAutoloadNamespace($config['driver']['annotations']['class']);
     AnnotationRegistry::registerFile('vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     $driver = new AnnotationDriver(new AnnotationReader(), $config['driver']['annotations']['paths']);
     $doctrine->setMetadataDriverImpl($driver);
     // Cache
     $cache = $container->get(\Doctrine\Common\Cache\Cache::class);
     $doctrine->setQueryCacheImpl($cache);
     $doctrine->setResultCacheImpl($cache);
     $doctrine->setMetadataCacheImpl($cache);
     // EntityManager
     return EntityManager::create($config['connection']['orm_default']['params'], $doctrine);
 }
开发者ID:vasildakov,项目名称:expressive-doctrine-orm,代码行数:37,代码来源:DoctrineFactory.php

示例9: __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

示例10: create

 /**
  * {@inheritdoc}
  */
 public static function create($conn, Configuration $config, EventManager $eventManager = null)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     switch (true) {
         case is_array($conn):
             if (!$eventManager) {
                 $eventManager = new EventManager();
             }
             if (isset($conn['prefix']) && $conn['prefix']) {
                 $eventManager->addEventListener(Events::loadClassMetadata, new TablePrefix($conn['prefix']));
             }
             $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
             break;
         case $conn instanceof Connection:
             if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
                 throw ORMException::mismatchedEventManager();
             }
             break;
         default:
             throw new \InvalidArgumentException("Invalid argument: " . $conn);
     }
     return new self($conn, $config, $conn->getEventManager());
 }
开发者ID:minchal,项目名称:vero,代码行数:28,代码来源:EntityManager.php

示例11: __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:s4if,项目名称:ppdb-sma,代码行数:31,代码来源:Doctrine.php

示例12: loadDoctrine

 private function loadDoctrine($dbname, $host, $username, $password)
 {
     $lib = APPLICATION_PATH . "/doctrine-orm";
     Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($lib);
     if (APPLICATION_ENV == "production") {
         $cache = new \Doctrine\Common\Cache\ApcCache();
     } else {
         $cache = new \Doctrine\Common\Cache\ArrayCache();
     }
     $config = new Configuration();
     $config->setMetadataCacheImpl($cache);
     $driverImpl = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/modules/default/models');
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir(APPLICATION_PATH . '/Proxies');
     $config->setProxyNamespace('EasyCMS\\Proxies');
     if ($applicationMode == "production") {
         $config->setAutoGenerateProxyClasses(false);
     } else {
         $config->setAutoGenerateProxyClasses(true);
     }
     $connectionOptions = array('driver' => 'pdo_mysql', 'dbname' => $dbname, 'user' => $username, 'password' => $password, 'host' => $host);
     $em = EntityManager::create($connectionOptions, $config);
     Zend_Registry::set('**application_db_connection**', $em);
 }
开发者ID:robinmbarnes,项目名称:EasyCMS,代码行数:25,代码来源:Bootstrap.php

示例13: __construct

 public function __construct($config)
 {
     if (isset($config["doctrine"])) {
         $dbParams = $config["doctrine"]["db_params"];
         $paths = StringCommon::replaceKeyWords($config["doctrine"]["entity_paths"]);
         $isDevMode = $config["doctrine"]["is_dev_mode"];
         $proxyDir = StringCommon::replaceKeyWords($config["doctrine"]["proxy_dir"]);
         $proxyNamespace = $config["doctrine"]["proxy_namespace"];
         $applicationMode = Game::getInstance()->getApplicationMode();
         if ($applicationMode == Game::DEVELOPMENT_MODE) {
             $cache = new \Doctrine\Common\Cache\ArrayCache();
         } else {
             $cache = new \Doctrine\Common\Cache\ApcCache();
         }
         $doctrineConfig = new Configuration();
         $doctrineConfig->setMetadataCacheImpl($cache);
         $driverImpl = $doctrineConfig->newDefaultAnnotationDriver($paths);
         $doctrineConfig->setMetadataDriverImpl($driverImpl);
         $doctrineConfig->setQueryCacheImpl($cache);
         $doctrineConfig->setProxyDir($proxyDir);
         $doctrineConfig->setProxyNamespace($proxyNamespace);
         if ($applicationMode == Game::DEVELOPMENT_MODE) {
             $doctrineConfig->setAutoGenerateProxyClasses(true);
         } else {
             $doctrineConfig->setAutoGenerateProxyClasses(false);
         }
         $entityManager = EntityManager::create($dbParams, $doctrineConfig);
         Game::getInstance()->getContainer()->set("entity_manager", $entityManager);
     } else {
         throw new \RuntimeException("You need add Doctrine config in your res/config.yml");
     }
 }
开发者ID:mbabenko21,项目名称:likedimion-server,代码行数:32,代码来源:DoctrineBootstrap.php

示例14: entity_manager

 /**
  * Creates a new EntityManager instance based on the provided configuration.
  *
  *     $factory = new Doctrine_EMFactory;
  *     $em = $factory->entity_manager();
  *
  * @param string $db_group the name of the Kohana database config group to get connection information from
  *
  * @return \Doctrine\ORM\EntityManager
  */
 public function entity_manager($db_group = 'default')
 {
     $config = $this->config->load('doctrine');
     // Ensure the composer autoloader is registered
     require_once $config['composer_vendor_path'] . 'autoload.php';
     // Create the Configuration class
     $orm_config = new Configuration();
     // Create the metadata driver
     $driver = $this->create_annotation_driver();
     $orm_config->setMetadataDriverImpl($driver);
     // Configure the proxy directory and namespace
     $orm_config->setProxyDir($config['proxy_dir']);
     $orm_config->setProxyNamespace($config['proxy_namespace']);
     if ($config->get('use_underscore_naming_strategy')) {
         $naming_strategy = new UnderscoreNamingStrategy($config->get('case_underscore_naming_strategy'));
         $orm_config->setNamingStrategy($naming_strategy);
     }
     // Configure environment-specific options
     if ($this->environment === Kohana::DEVELOPMENT) {
         $orm_config->setAutoGenerateProxyClasses(TRUE);
         $cache = new ArrayCache();
     } else {
         $orm_config->setAutoGenerateProxyClasses(FALSE);
         $cache = new ApcCache();
     }
     // Set the cache drivers
     $orm_config->setMetadataCacheImpl($cache);
     $orm_config->setQueryCacheImpl($cache);
     // Create the Entity Manager with the database connection information
     $em = EntityManager::create($this->get_connection_config($db_group), $orm_config);
     $this->register_custom_types($config);
     return $em;
 }
开发者ID:ingenerator,项目名称:kohana-doctrine2,代码行数:43,代码来源:EMFactory.php

示例15: getConfiguration

 /**
  * Add driverChain and get orm config
  *
  * @return \Doctrine\ORM\Configuration
  */
 public function getConfiguration()
 {
     $driverChain = $this->getMetadataDriverImpl();
     // Inject the driverChain into the doctrine config
     $this->configuration->setMetadataDriverImpl($driverChain);
     return $this->configuration;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:12,代码来源:EntityManagerConfigFactory.php


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