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


PHP Type::addType方法代码示例

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


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

示例1: installTypes

 public function installTypes()
 {
     foreach ($this->types as $type => $class) {
         if (!MongoDBType::hasType($type)) {
             MongoDBType::addType($type, $class);
         }
     }
 }
开发者ID:rhapsody-project,项目名称:crypto-bundle,代码行数:8,代码来源:TypeInstaller.php

示例2: onBootstrap

 /**
  * Sets up services on the bootstrap event.
  * 
  * @internal
  *     Creates the translation service and a ModuleRouteListener
  *      
  * @param MvcEvent $e
  */
 public function onBootstrap(MvcEvent $e)
 {
     // Register the TimezoneAwareDate type with DoctrineMongoODM
     // Use it in Annotions ( @Field(type="tz_date") )
     if (!DoctrineType::hasType('tz_date')) {
         DoctrineType::addType('tz_date', '\\Core\\Repository\\DoctrineMongoODM\\Types\\TimezoneAwareDate');
     }
     $sm = $e->getApplication()->getServiceManager();
     $translator = $sm->get('translator');
     // initialise translator!
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
     $eventManager = $e->getApplication()->getEventManager();
     $sharedManager = $eventManager->getSharedManager();
     #       $LogListener = new LogListener();
     #       $LogListener->attach($eventManager);
     if (!\Zend\Console\Console::isConsole()) {
         $redirectCallback = function () use($e) {
             $routeMatch = $e->getRouteMatch();
             $lang = $routeMatch ? $routeMatch->getParam('lang', 'en') : 'en';
             $uri = $e->getRouter()->getBaseUrl() . '/' . $lang . '/error';
             header('Location: ' . $uri);
         };
         $errorHandlerListener = new ErrorHandlerListener($sm->get('ErrorLogger'), $redirectCallback);
         $errorHandlerListener->attach($eventManager);
         $languageRouteListener = new LanguageRouteListener();
         $languageRouteListener->attach($eventManager);
         $ajaxRenderListener = new AjaxRenderListener();
         $ajaxRenderListener->attach($eventManager);
         $enforceJsonResponseListener = new EnforceJsonResponseListener();
         $enforceJsonResponseListener->attach($eventManager);
         $stringListener = new StringListener();
         $stringListener->attach($eventManager);
         //
         $notificationlistener = $sm->get('Core/Listener/Notification');
         $notificationlistener->attachShared($sharedManager);
         $notificationAjaxHandler = new NotificationAjaxHandler();
         $eventManager->attach(MvcEvent::EVENT_DISPATCH, array($notificationAjaxHandler, 'injectView'), -20);
         $notificationlistener->attach(NotificationEvent::EVENT_NOTIFICATION_HTML, array($notificationAjaxHandler, 'render'), -20);
     }
     $persistenceListener = new PersistenceListener();
     $persistenceListener->attach($eventManager);
     $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function ($event) {
         $application = $event->getApplication();
         if ($application::ERROR_EXCEPTION == $event->getError()) {
             $ex = $event->getParam('exception');
             if (404 == $ex->getCode()) {
                 $event->setError($application::ERROR_CONTROLLER_NOT_FOUND);
             }
         }
     }, 500);
     $eventManager->attach(MvcEvent::EVENT_DISPATCH, function ($event) use($eventManager) {
         $eventManager->trigger('postDispatch', $event);
     }, -150);
 }
开发者ID:vfulco,项目名称:YAWIK,代码行数:62,代码来源:Module.php

示例3: dm

 /**
  * @return \Doctrine\ODM\MongoDB\DocumentManager
  */
 public function dm()
 {
     if ($this->dm === null) {
         $this->dm = $this->createTestDocumentManager();
         $this->uow = $this->dm->getUnitOfWork();
         Type::addType('Phonenumber', PhonenumberType::class);
         Type::addType('Role', RoleType::class);
         $this->dm->getEventManager()->addEventSubscriber(new MetadataEventSubscriber());
         $this->dm->getEventManager()->addEventSubscriber(new CollectionsEventSubscriber());
         $this->dm->getEventManager()->addEventSubscriber(new ModelEventSubscriber());
         $this->dm->getEventManager()->addEventSubscriber(new IdentityEventSubscriber());
         $this->dm->getEventManager()->addEventSubscriber(new GeolocationEventSubscriber());
         $this->dm->getEventManager()->addEventSubscriber(new SystemEventSubscriber());
     }
     return $this->dm;
 }
开发者ID:cubiche,项目名称:cubiche,代码行数:19,代码来源:DocumentManagerTestCaseTrait.php

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

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

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

示例7: createStorage

 /**
  * {@inheritDoc}
  */
 public function createStorage($modelClass, $idProperty, array $options)
 {
     if (false == Type::hasType('object')) {
         Type::addType('object', 'Payum\\Core\\Bridge\\Doctrine\\Types\\ObjectType');
     }
     $driver = new MappingDriverChain();
     // payum's basic models
     $coreRootDir = dirname((new \ReflectionClass(GatewayInterface::class))->getFileName());
     $driver->addDriver(new XmlDriver(new SymfonyFileLocator(array($coreRootDir . '/Bridge/Doctrine/Resources/mapping' => 'Payum\\Core\\Model'), '.mongodb.xml'), '.mongodb.xml'), 'Payum\\Core\\Model');
     // your models
     $sererRootDir = dirname((new \ReflectionClass(Application::class))->getFileName());
     AnnotationDriver::registerAnnotationClasses();
     $driver->addDriver(new AnnotationDriver(new AnnotationReader(), array($sererRootDir . '/Model')), 'Payum\\Server\\Model');
     $config = new Configuration();
     $config->setProxyDir(\sys_get_temp_dir() . '/PayumServer');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(\sys_get_temp_dir() . '/PayumServer');
     $config->setHydratorNamespace('Hydrators');
     $config->setMetadataDriverImpl($driver);
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setDefaultDB($options['databaseName']);
     $connection = new Connection($options['host'], array(), $config);
     return new DoctrineStorage(DocumentManager::create($connection, $config), $modelClass);
 }
开发者ID:Headd2k,项目名称:PayumServer,代码行数:27,代码来源:DoctrineMongoDbFactory.php

示例8:

<?php

use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
use Composer\Autoload\ClassLoader;
/**
 * @var ClassLoader $loader
 */
$loader = (require __DIR__ . '/../vendor/autoload.php');
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
AnnotationDriver::registerAnnotationClasses();
use Doctrine\ODM\MongoDB\Types\Type;
Type::addType('coordinates', 'Khepin\\BookBundle\\Document\\CoordinatesType');
return $loader;
开发者ID:bswiatek,项目名称:sym2rf,代码行数:14,代码来源:autoload.php

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

示例10: register


//.........这里部分代码省略.........
                         $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;
     });
     $container['mongodbodm.cache.factory.backing_memcache'] = $container->protect(function () {
开发者ID:saxulum,项目名称:saxulum-doctrine-mongodb-odm-provider,代码行数:67,代码来源:DoctrineMongoDbOdmProvider.php

示例11: checkArrayCollectionType

 /**
  * @param ClassMetadata $classMetadata
  *
  * @throws MappingException
  */
 protected function checkArrayCollectionType(ClassMetadata $classMetadata)
 {
     foreach ($classMetadata->fieldMappings as $fieldName => $mapping) {
         if (isset($mapping['embedded']) || isset($mapping['reference'])) {
             continue;
         }
         if (isset($mapping['cubiche:collection'])) {
             $collectionMapping = $mapping['cubiche:collection'];
             if ($collectionMapping['of'] === null) {
                 throw MappingException::inField('The "of" option in ' . $collectionMapping['type'] . ' type is missing', $classMetadata->name, $fieldName);
             }
             $type = $collectionMapping['of'] . $collectionMapping['type'];
             if (!Type::hasType($type)) {
                 Type::addType($type, $collectionMapping['typeClassName']);
                 Type::getType($type)->setInnerType($collectionMapping['of']);
             }
             $classMetadata->fieldMappings[$fieldName]['type'] = $type;
         }
     }
 }
开发者ID:cubiche,项目名称:cubiche,代码行数:25,代码来源:EventListener.php

示例12: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     Type::addType('date_collection', __NAMESPACE__ . '\\DateCollectionType');
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:4,代码来源:CustomTypeTest.php

示例13: boot

 public function boot()
 {
     Type::addType('object', 'Payum\\Core\\Bridge\\Doctrine\\Types\\ObjectType');
     parent::boot();
 }
开发者ID:partkeepr,项目名称:PayumBundleSandbox,代码行数:5,代码来源:AppKernel.php


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