本文整理匯總了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();
}
}
示例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;
}
示例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();
}
}
示例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);
}
}
}
}
示例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