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


PHP Configuration::setAutoGenerateProxyClasses方法代码示例

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


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

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

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

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

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

示例5: register

 public function register()
 {
     $this->container['object_manager'] = function () {
         $development = false;
         if (defined('ENVIRONMENT') && ENVIRONMENT === 'development') {
             $development = true;
         }
         $config = new Configuration();
         if ($development) {
             $cache = new ArrayCache();
         } else {
             $cache = new ApcCache();
         }
         $config->setMetadataCacheImpl($cache);
         $mappings = $this->container->get('config')['orm']['mappings'];
         $config->setMetadataDriverImpl(new XmlDriver($mappings));
         $proxyDir = $this->container->get('config')['orm']['proxy_dir'];
         $config->setProxyDir($proxyDir);
         $config->setQueryCacheImpl($cache);
         $config->setProxyNamespace('Jirro\\ORM\\Proxies');
         if ($development) {
             $config->setAutoGenerateProxyClasses(true);
         } else {
             $config->setAutoGenerateProxyClasses(false);
         }
         $dbConnection = $this->container->get('db_connection');
         $objectManager = ObjectManager::create($dbConnection, $config);
         return $objectManager;
     };
     $this->container->inflector('Jirro\\Component\\ORM\\ObjectManagerAwareInterface')->invokeMethod('setObjectManager', ['object_manager']);
 }
开发者ID:jirro,项目名称:orm,代码行数:31,代码来源:ORMServiceProvider.php

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

示例7: factory

 /**
  * @param array $settings
  * @param bool $debug
  * @return EntityManager
  * @throws \Doctrine\ORM\ORMException
  */
 public static function factory($settings, $debug = true)
 {
     if ($debug || !function_exists('apc_fetch')) {
         $cache = new ArrayCache();
     } else {
         $cache = new ApcCache();
     }
     $dbSettings = $settings['doctrine'];
     $config = new Configuration();
     $config->setMetadataCacheImpl($cache);
     // Do not use default Annotation driver
     $driverImpl = new AnnotationDriver(new AnnotationReader(), $dbSettings['entities']);
     // Allow all annotations
     AnnotationRegistry::registerLoader('class_exists');
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir($dbSettings['proxy_path']);
     $config->setProxyNamespace('Zaralab\\Doctrine\\Proxies');
     if ($debug) {
         $config->setAutoGenerateProxyClasses(true);
     } else {
         $config->setAutoGenerateProxyClasses(false);
     }
     $connectionOptions = $dbSettings['dbal'];
     return EntityManager::create($connectionOptions, $config);
 }
开发者ID:myovchev,项目名称:zaralab-api,代码行数:32,代码来源:Doctrine.php

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

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

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

示例12: setUpEntityManager

 protected static function setUpEntityManager()
 {
     $config = new Configuration();
     $config->setSQLLogger(null);
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setProxyNamespace('Proxies');
     $config->setMetadataDriverImpl(static::getMetadataDriverImpl());
     $config->setQueryCacheImpl(new ArrayCache());
     $config->setMetadataCacheImpl(new ArrayCache());
     $dbPath = __DIR__ . '/../db.sqlite';
     if (file_exists($dbPath)) {
         unlink($dbPath);
     }
     $connection = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
     // Event listeners
     $interfaces = DoctrineBundleMapping::getDefaultImplementations();
     $evm = new EventManager();
     // Resolve entity target subscriber
     $rtel = new ResolveTargetEntityListener();
     foreach ($interfaces as $model => $implementation) {
         $rtel->addResolveTargetEntity($model, $implementation, []);
     }
     $evm->addEventSubscriber($rtel);
     // Load metadata subscriber
     $lm = new LoadMetadataSubscriber([], $interfaces);
     $evm->addEventSubscriber($lm);
     static::$em = EntityManager::create($connection, $config, $evm);
 }
开发者ID:ekyna,项目名称:commerce,代码行数:29,代码来源:OrmTestCase.php

示例13: setUp

    public function setUp()
    {
        if (!$this->entityManager) {
            EntityManagerContainer::clearEntityManager();

            $configuration = new Configuration();
            $configuration->setMetadataDriverImpl(new StaticPHPDriver(__DIR__.'/../../Model'));
            $configuration->setProxyDir(__DIR__.'/../../Proxy');
            $configuration->setProxyNamespace('Proxy');
            $configuration->setAutoGenerateProxyClasses(true);

            $this->entityManager = EntityManager::create(array(
                'driver' => 'pdo_sqlite',
                'path'   => ':memory:',
            ), $configuration);

            // event manager
            $this->eventManager = $this->entityManager->getEventManager();

            // metadata factory
            $this->metadataFactory = $this->entityManager->getMetadataFactory();

            // create schema
            $schemaTool = new SchemaTool($this->entityManager);
            $schemaTool->createSchema($this->metadataFactory->getAllMetadata());

            // entity manager container
            EntityManagerContainer::setEntityManager($this->entityManager);
        }
    }
开发者ID:regisg27,项目名称:Propel2,代码行数:30,代码来源:TestCase.php

示例14: createEntityManager

 /**
  * @return \Doctrine\ORM\EntityManager
  */
 protected function createEntityManager()
 {
     // event manager used to create schema before tests
     $eventManager = new EventManager();
     $eventManager->addEventListener(array("preTestSetUp"), new SchemaSetupListener());
     // doctrine xml configs and namespaces
     $configPathList = array();
     if (is_dir(__DIR__ . '/../Resources/config/doctrine')) {
         $dir = __DIR__ . '/../Resources/config/doctrine';
         $configPathList[] = $dir;
         $prefixList[$dir] = 'Kitpages\\DataGridBundle\\Entities';
     }
     if (is_dir(__DIR__ . '/_doctrine/config')) {
         $dir = __DIR__ . '/_doctrine/config';
         $configPathList[] = $dir;
         $prefixList[$dir] = 'Kitpages\\DataGridBundle\\Tests\\TestEntities';
     }
     // create drivers (that reads xml configs)
     $driver = new \Symfony\Bridge\Doctrine\Mapping\Driver\XmlDriver($configPathList);
     $driver->setNamespacePrefixes($prefixList);
     // create config object
     $config = new Configuration();
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setMetadataDriverImpl($driver);
     $config->setProxyDir(__DIR__ . '/TestProxies');
     $config->setProxyNamespace('Kitpages\\DataGridBundle\\Tests\\TestProxies');
     $config->setAutoGenerateProxyClasses(true);
     //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     // create entity manager
     $em = EntityManager::create(array('driver' => 'pdo_sqlite', 'path' => "/tmp/sqlite-test.db"), $config, $eventManager);
     return $em;
 }
开发者ID:radmar,项目名称:KitpagesDataGridBundle,代码行数:35,代码来源:BundleOrmTestCase.php

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


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