當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Type::overrideType方法代碼示例

本文整理匯總了PHP中Doctrine\ODM\MongoDB\Types\Type::overrideType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Type::overrideType方法的具體用法?PHP Type::overrideType怎麽用?PHP Type::overrideType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ODM\MongoDB\Types\Type的用法示例。


在下文中一共展示了Type::overrideType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     Type::hasType('object') ? Type::overrideType('object', 'Payum\\Core\\Bridge\\Doctrine\\Types\\ObjectType') : Type::addType('object', 'Payum\\Core\\Bridge\\Doctrine\\Types\\ObjectType');
     $config = new Configuration();
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setProxyNamespace('PayumTestsProxies');
     $config->setHydratorDir(\sys_get_temp_dir());
     $config->setHydratorNamespace('PayumTestsHydrators');
     $config->setMetadataDriverImpl($this->getMetadataDriverImpl($config));
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setDefaultDB('payum_tests');
     $connection = new Connection(null, array(), $config);
     $this->dm = DocumentManager::create($connection, $config);
     foreach ($this->dm->getConnection()->selectDatabase('payum_tests')->listCollections() as $collection) {
         $collection->drop();
     }
 }
開發者ID:stan5621,項目名稱:eduwind,代碼行數:17,代碼來源:BaseMongoTest.php

示例2: createService

 /**
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return \Doctrine\ODM\MongoDB\Configuration
  * @throws \Exception
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var $options \DoctrineMongoODMModule\Options\Configuration */
     $options = $this->getOptions($serviceLocator, 'configuration');
     $config = new Configuration();
     // logger
     if ($options->getLogger()) {
         $logger = $serviceLocator->get($options->getLogger());
         $config->setLoggerCallable(array($logger, 'log'));
     }
     // proxies
     $config->setAutoGenerateProxyClasses($options->getGenerateProxies());
     $config->setProxyDir($options->getProxyDir());
     $config->setProxyNamespace($options->getProxyNamespace());
     // hydrators
     $config->setAutoGenerateHydratorClasses($options->getGenerateHydrators());
     $config->setHydratorDir($options->getHydratorDir());
     $config->setHydratorNamespace($options->getHydratorNamespace());
     // default db
     $config->setDefaultDB($options->getDefaultDb());
     // caching
     $config->setMetadataCacheImpl($serviceLocator->get($options->getMetadataCache()));
     // retries
     $config->setRetryConnect($options->getRetryConnect());
     $config->setRetryQuery($options->getRetryQuery());
     // Register filters
     foreach ($options->getFilters() as $alias => $class) {
         $config->addFilter($alias, $class);
     }
     // the driver
     $config->setMetadataDriverImpl($serviceLocator->get($options->getDriver()));
     // metadataFactory, if set
     if ($factoryName = $options->getClassMetadataFactoryName()) {
         $config->setClassMetadataFactoryName($factoryName);
     }
     // custom types
     foreach ($options->getTypes() as $name => $class) {
         if (Type::hasType($name)) {
             Type::overrideType($name, $class);
         } else {
             Type::addType($name, $class);
         }
     }
     return $config;
 }
開發者ID:RageZBla,項目名稱:DoctrineMongoODMModule,代碼行數:50,代碼來源:ConfigurationFactory.php

示例3: setUp

 public function setUp()
 {
     $this->skipTestsIfPhp7();
     if (false == (class_exists(\MongoId::class) && class_exists(Connection::class))) {
         $this->markTestSkipped('Either mongo extension or\\and doctrine\\mongo-odm are not installed.');
     }
     Type::hasType('object') ? Type::overrideType('object', 'Payum\\Core\\Bridge\\Doctrine\\Types\\ObjectType') : Type::addType('object', 'Payum\\Core\\Bridge\\Doctrine\\Types\\ObjectType');
     $config = new Configuration();
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setProxyNamespace('PayumTestsProxies');
     $config->setHydratorDir(\sys_get_temp_dir());
     $config->setHydratorNamespace('PayumTestsHydrators');
     $config->setMetadataDriverImpl($this->getMetadataDriverImpl($config));
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setDefaultDB('payum_tests');
     $connection = new Connection(null, array(), $config);
     $this->dm = DocumentManager::create($connection, $config);
     foreach ($this->dm->getConnection()->selectDatabase('payum_tests')->listCollections() as $collection) {
         $collection->drop();
     }
 }
開發者ID:piotrantosik,項目名稱:Payum,代碼行數:21,代碼來源:BaseMongoTest.php

示例4: configureDocumentManager

 /**
  * Configures the Doctrine entity manager instance.
  *
  * @param array           $doctrineConfig
  * @param DocumentManager $documentManager
  */
 protected function configureDocumentManager(array $doctrineConfig, DocumentManager $documentManager)
 {
     if (isset($doctrineConfig['filters'])) {
         foreach ($doctrineConfig['filters'] as $name => $filter) {
             if (!array_get($filter, 'enabled', false)) {
                 continue;
             }
             $documentManager->getFilterCollection()->enable($name);
         }
     }
     // @see http://doctrine-mongodb-odm.readthedocs.org/en/latest/reference/basic-mapping.html#custom-mapping-types
     if (isset($doctrineConfig['types'])) {
         foreach ($doctrineConfig['types'] as $name => $className) {
             if (!Type::hasType($name)) {
                 Type::addType($name, $className);
             } else {
                 Type::overrideType($name, $className);
             }
         }
     }
 }
開發者ID:nordsoftware,項目名稱:lumen-doctrine-mongodb-odm,代碼行數:27,代碼來源:DoctrineServiceProvider.php

示例5: register


//.........這裏部分代碼省略.........
                     case 'annotation':
                         $useSimpleAnnotationReader = isset($entity['use_simple_annotation_reader']) ? $entity['use_simple_annotation_reader'] : true;
                         $driver = $config->newDefaultAnnotationDriver((array) $entity['path'], $useSimpleAnnotationReader);
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     case 'yml':
                         $driver = new YamlDriver($entity['path']);
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     case 'simple_yml':
                         $driver = new SimplifiedYamlDriver(array($entity['path'] => $entity['namespace']));
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     case 'xml':
                         $driver = new XmlDriver($entity['path']);
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     case 'simple_xml':
                         $driver = new SimplifiedXmlDriver(array($entity['path'] => $entity['namespace']));
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     case 'php':
                         $driver = new StaticPHPDriver($entity['path']);
                         $chain->addDriver($driver, $entity['namespace']);
                         break;
                     default:
                         throw new \InvalidArgumentException(sprintf('"%s" is not a recognized driver', $entity['type']));
                         break;
                 }
             }
             $config->setMetadataDriverImpl($chain);
             foreach ((array) $options['types'] as $typeName => $typeClass) {
                 if (Type::hasType($typeName)) {
                     Type::overrideType($typeName, $typeClass);
                 } else {
                     Type::addType($typeName, $typeClass);
                 }
             }
             $configs[$name] = $config;
         }
         return $configs;
     };
     $container['mongodbodm.cache.configurer'] = $container->protect(function ($name, Configuration $config, $options) use($container) {
         $config->setMetadataCacheImpl($container['mongodbodm.cache.locator']($name, 'metadata', $options));
     });
     $container['mongodbodm.cache.locator'] = $container->protect(function ($name, $cacheName, $options) use($container) {
         $cacheNameKey = $cacheName . '_cache';
         if (!isset($options[$cacheNameKey])) {
             $options[$cacheNameKey] = $container['mongodbodm.default_cache'];
         }
         if (isset($options[$cacheNameKey]) && !is_array($options[$cacheNameKey])) {
             $options[$cacheNameKey] = array('driver' => $options[$cacheNameKey]);
         }
         if (!isset($options[$cacheNameKey]['driver'])) {
             throw new \RuntimeException("No driver specified for '{$cacheName}'");
         }
         $driver = $options[$cacheNameKey]['driver'];
         $cacheInstanceKey = 'mongodbodm.cache.instances.' . $name . '.' . $cacheName;
         if (isset($container[$cacheInstanceKey])) {
             return $container[$cacheInstanceKey];
         }
         $cache = $container['mongodbodm.cache.factory']($driver, $options[$cacheNameKey]);
         if (isset($options['cache_namespace']) && $cache instanceof CacheProvider) {
             $cache->setNamespace($options['cache_namespace']);
         }
         return $container[$cacheInstanceKey] = $cache;
開發者ID:saxulum,項目名稱:saxulum-doctrine-mongodb-odm-provider,代碼行數:67,代碼來源:DoctrineMongoDbOdmProvider.php


注:本文中的Doctrine\ODM\MongoDB\Types\Type::overrideType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。