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


PHP Configuration::setMetadataDriverImpl方法代码示例

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


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

示例1: 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

示例2: obterConfiguracao

 private function obterConfiguracao($dados)
 {
     $this->config = new Configuration();
     // Definição do driver de mapeamento
     $metadata_driver = "Doctrine\\ORM\\Mapping\\Driver\\{$dados['metadata_driver']}";
     if ($dados['metadata_driver'] == "AnnotationDriver") {
         $driver = $this->config->newDefaultAnnotationDriver(array(MODELO), true);
     } else {
         $driver = new $metadata_driver(CONFIG . DS . 'orm');
     }
     if (!empty($dados['map_paths'])) {
         $driver->addPaths(preg_split('/, ?/', $dados['map_paths']));
     }
     $this->config->setMetadataDriverImpl($driver);
     // Configurações de proxies
     $this->config->setProxyDir(RAIZ . DS . $dados['proxy_dir']);
     $this->config->setProxyNamespace($dados['proxy_namespace']);
     $this->config->setAutoGenerateProxyClasses($dados['auto_proxies']);
     // Definição da estratégia de caches de consultas e metadados
     $metadata_cache = "Doctrine\\Common\\Cache\\{$dados['metadata_cache']}";
     $query_cache = "Doctrine\\Common\\Cache\\{$dados['query_cache']}";
     $result_cache = "Doctrine\\Common\\Cache\\{$dados['query_cache']}";
     $this->config->setMetadataCacheImpl(new $metadata_cache());
     $this->config->setQueryCacheImpl(new $query_cache());
     $this->config->setResultCacheImpl(new $result_cache());
     // Ferramenta de log de consultas
     if (!empty($dados['sql_logger'])) {
         $sql_logger = "Doctrine\\DBAL\\Logging\\{$dados['sql_logger']}";
         $logger = new $sql_logger();
         $this->config->setSQLLogger($logger);
     }
 }
开发者ID:jjaferson,项目名称:ourives,代码行数:32,代码来源:DoctrinePlugin.php

示例3: getConfig

 /**
  * Get the Doctrine Configuration object
  *
  * @return \Doctrine\ORM\Configuration
  */
 public function getConfig()
 {
     if (null === $this->_config) {
         $this->_config = new \Doctrine\ORM\Configuration();
         $this->_config->setMetadataDriverImpl($this->getDriver());
     }
     return $this->_config;
 }
开发者ID:Bittarman,项目名称:d2-zf-sandbox,代码行数:13,代码来源:Doctrine.php

示例4: testSetGetMetadataDriverImpl

 public function testSetGetMetadataDriverImpl()
 {
     $this->assertSame(null, $this->configuration->getMetadataDriverImpl());
     // defaults
     $metadataDriver = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver');
     $this->configuration->setMetadataDriverImpl($metadataDriver);
     $this->assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:8,代码来源:ConfigurationTest.php

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

示例6: setUp

 public function setUp()
 {
     $this->configuration = new Configuration();
     $this->configuration->setMetadataCacheImpl(new ArrayCache());
     $this->configuration->setQueryCacheImpl(new ArrayCache());
     $this->configuration->setProxyDir(__DIR__ . '/Proxies');
     $this->configuration->setProxyNamespace('DoctrineExtensions\\Tests\\Proxies');
     $this->configuration->setAutoGenerateProxyClasses(true);
     $this->configuration->setMetadataDriverImpl($this->configuration->newDefaultAnnotationDriver(__DIR__ . '/../Entities'));
     $this->entityManager = EntityManager::create(array('driver' => 'pdo_sqlite', 'memory' => true), $this->configuration);
 }
开发者ID:beberlei,项目名称:DoctrineExtensions,代码行数:11,代码来源:DbTestCase.php

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

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

示例9: _initDoctrine

 protected function _initDoctrine()
 {
     $config = new Configuration();
     switch (APPLICATION_ENV) {
         case 'production':
         case 'staging':
             $cache = new \Doctrine\Common\Cache\ApcCache();
             break;
             // Both development and test environments will use array cache.
         // Both development and test environments will use array cache.
         default:
             $cache = new \Doctrine\Common\Cache\ArrayCache();
             break;
     }
     $config->setMetadataCacheImpl($cache);
     $driverImpl = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/models');
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir(APPLICATION_PATH . '/proxies');
     $config->setProxyNamespace('D2Test\\Proxies');
     $options = $this->getOption('doctrine');
     $config->setAutoGenerateProxyClasses($options['auto_generate_proxy_class']);
     $em = EntityManager::create($options['db'], $config);
     Zend_Registry::set('EntityManager', $em);
     return $em;
 }
开发者ID:bzarzuela,项目名称:Doctrine-2-Blog-Example,代码行数:26,代码来源:Bootstrap.php

示例10: __construct

 public function __construct()
 {
     if (defined('FCPATH')) {
         //Get CI instance
         $this->ci = CI_Controller::get_instance();
         //Load database configuration from CodeIgniter
         $this->db = $this->ci->db;
         //Database connection information
         $connectionOptions = array('user' => $this->db->username, 'password' => $this->db->password, 'host' => $this->db->hostname, 'dbname' => $this->db->database);
     } elseif (ENVIRONMENT === 'development') {
         include_once str_replace("/", DIRECTORY_SEPARATOR, APPPATH) . 'config' . DIRECTORY_SEPARATOR . 'development' . DIRECTORY_SEPARATOR . 'database.php';
         $connectionOptions = array('user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
     }
     $connectionOptions['driver'] = 'pdo_mysql';
     $connectionOptions['charset'] = 'utf8';
     $connectionOptions['driverOptions'] = array(1002 => 'SET NAMES utf8');
     $config = new Configuration();
     //Set up caches
     $cache = new ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     //Set up Annotation
     $driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
     $config->setMetadataDriverImpl($driverImpl);
     //Proxy configuration
     $config->setProxyDir(APPPATH . '/models/proxies');
     $config->setProxyNamespace('Proxies');
     $config->setAutoGenerateProxyClasses(TRUE);
     // Create EntityManager
     $this->em = EntityManager::create($connectionOptions, $config);
     //Fix the problem: "unknown database type enum requested"
     $platform = $this->em->getConnection()->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('enum', 'string');
 }
开发者ID:ricardoandrietta,项目名称:skeleton-ci,代码行数:34,代码来源:Doctrine.php

示例11: register

 public function register(Application $app)
 {
     //Load Doctrine Configuration
     $app['db.configuration'] = $app->share(function () use($app) {
         AnnotationRegistry::registerAutoloadNamespace("Doctrine\\ORM\\Mapping", __DIR__ . '/../../../../../doctrine/orm/lib');
         $config = new ORMConfiguration();
         $cache = $app['debug'] == false ? new ApcCache() : new ArrayCache();
         $config->setMetadataCacheImpl($cache);
         $config->setQueryCacheImpl($cache);
         $chain = new DriverChain();
         foreach ((array) $app['db.orm.entities'] as $entity) {
             switch ($entity['type']) {
                 case 'annotation':
                     $reader = new AnnotationReader();
                     $driver = new AnnotationDriver($reader, (array) $entity['path']);
                     $chain->addDriver($driver, $entity['namespace']);
                     break;
                     /*case 'yml':
                           $driver = new YamlDriver((array)$entity['path']);
                           $driver->setFileExtension('.yml');
                           $chain->addDriver($driver, $entity['namespace']);
                           break;
                       case 'xml':
                           $driver = new XmlDriver((array)$entity['path'], $entity['namespace']);
                           $driver->setFileExtension('.xml');
                           $chain->addDriver($driver, $entity['namespace']);
                           break;*/
                 /*case 'yml':
                       $driver = new YamlDriver((array)$entity['path']);
                       $driver->setFileExtension('.yml');
                       $chain->addDriver($driver, $entity['namespace']);
                       break;
                   case 'xml':
                       $driver = new XmlDriver((array)$entity['path'], $entity['namespace']);
                       $driver->setFileExtension('.xml');
                       $chain->addDriver($driver, $entity['namespace']);
                       break;*/
                 default:
                     throw new \InvalidArgumentException(sprintf('"%s" is not a recognized driver', $type));
                     break;
             }
         }
         $config->setMetadataDriverImpl($chain);
         $config->setProxyDir($app['db.orm.proxies_dir']);
         $config->setProxyNamespace($app['db.orm.proxies_namespace']);
         $config->setAutoGenerateProxyClasses($app['db.orm.auto_generate_proxies']);
         return $config;
     });
     //Set Defaut Configuration
     $defaults = array('entities' => array(array('type' => 'annotation', 'path' => 'Entity', 'namespace' => 'Entity')), 'proxies_dir' => 'cache/doctrine/Proxy', 'proxies_namespace' => 'DoctrineProxy', 'auto_generate_proxies' => true);
     foreach ($defaults as $key => $value) {
         if (!isset($app['db.orm.' . $key])) {
             $app['db.orm.' . $key] = $value;
         }
     }
     $self = $this;
     $app['db.orm.em'] = $app->share(function () use($self, $app) {
         return EntityManager::create($app['db'], $app['db.configuration']);
     });
 }
开发者ID:amenophis,项目名称:silex-doctrineorm,代码行数:60,代码来源:DoctrineORMServiceProvider.php

示例12: 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

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

示例14: _initEntityManager

 /**
  * Init the doctrine entity manager.
  *
  * @return Doctrine\ORM\EntityManager
  */
 private function _initEntityManager()
 {
     // New database configuration
     $config = new Configuration();
     $driverImpl = $config->newDefaultAnnotationDriver();
     $config->setMetadataDriverImpl($driverImpl);
     $proxiesPath = $this->_application->getCacheDir() . DIRECTORY_SEPARATOR . 'Proxies';
     $config->setProxyDir($proxiesPath);
     $config->setProxyNamespace('Proxies');
     // Create EntityManager
     $em = EntityManager::create($this->_config, $config);
     if (isset($this->_config['charset'])) {
         try {
             $em->getConnection()->executeUpdate('SET SESSION character_set_client = "' . addslashes($this->_config['charset']) . '";');
             $em->getConnection()->executeUpdate('SET SESSION character_set_connection = "' . addslashes($this->_config['charset']) . '";');
             $em->getConnection()->executeUpdate('SET SESSION character_set_results = "' . addslashes($this->_config['charset']) . '";');
         } catch (\Exception $e) {
             throw new BBException(sprintf('Invalid database character set `%s`', $this->_config['charset']), BBException::INVALID_ARGUMENT, $e);
         }
     }
     if (isset($this->_config['collation'])) {
         try {
             $em->getConnection()->executeUpdate('SET SESSION collation_connection = "' . addslashes($this->_config['collation']) . '";');
         } catch (\Exception $e) {
             throw new BBException(sprintf('Invalid database collation `%s`', $this->_config['collation']), BBException::INVALID_ARGUMENT, $e);
         }
     }
     return $em;
 }
开发者ID:nextinteractive,项目名称:Importer,代码行数:34,代码来源:DataBase.php

示例15: loadDependencyDefaults

 public function loadDependencyDefaults(ContainerInterface $container)
 {
     // logger
     $container['logger'] = function (ContainerInterface $c) {
         $settings = $c->get('settings')['logger'];
         $debug = array_key_exists('debug', $settings) && $settings['debug'];
         $logger = new Logger($settings['name']);
         $logger->pushProcessor(new UidProcessor());
         $logger->pushHandler(new StreamHandler($settings['path'], $debug ? Logger::DEBUG : Logger::ERROR));
         return $logger;
     };
     // entity manager
     $container['entityManager'] = function (ContainerInterface $c) {
         $settings = $c->get('settings')['database'];
         $config = new Configuration();
         $config->setMetadataCacheImpl(new ArrayCache());
         $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . '/Entity'));
         $config->setMetadataDriverImpl($driverImpl);
         $config->setProxyDir(__DIR__ . '/Entity/Proxy');
         $config->setProxyNamespace('Proxy');
         return EntityManager::create($settings, $config);
     };
     $container['foundHandler'] = function () {
         return new RequestResponseArgs();
     };
     $container['dataFormatter'] = function () {
         return new ResponseDataFormatter();
     };
     return $container;
 }
开发者ID:vshvechko,项目名称:referaway,代码行数:30,代码来源:Configurator.php


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