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


PHP Configuration::addCustomHydrationMode方法代码示例

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


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

示例1: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var $options \DoctrineORMModule\Options\Configuration */
     $options = $this->getOptions($serviceLocator);
     $config = new Configuration();
     $config->setAutoGenerateProxyClasses($options->getGenerateProxies());
     $config->setProxyDir($options->getProxyDir());
     $config->setProxyNamespace($options->getProxyNamespace());
     $config->setEntityNamespaces($options->getEntityNamespaces());
     $config->setCustomDatetimeFunctions($options->getDatetimeFunctions());
     $config->setCustomStringFunctions($options->getStringFunctions());
     $config->setCustomNumericFunctions($options->getNumericFunctions());
     $config->setClassMetadataFactoryName($options->getClassMetadataFactoryName());
     foreach ($options->getNamedQueries() as $name => $query) {
         $config->addNamedQuery($name, $query);
     }
     foreach ($options->getNamedNativeQueries() as $name => $query) {
         $config->addNamedNativeQuery($name, $query['sql'], new $query['rsm']());
     }
     foreach ($options->getCustomHydrationModes() as $modeName => $hydrator) {
         $config->addCustomHydrationMode($modeName, $hydrator);
     }
     foreach ($options->getFilters() as $name => $class) {
         $config->addFilter($name, $class);
     }
     $config->setMetadataCacheImpl($serviceLocator->get($options->getMetadataCache()));
     $config->setQueryCacheImpl($serviceLocator->get($options->getQueryCache()));
     $config->setResultCacheImpl($serviceLocator->get($options->getResultCache()));
     $config->setHydrationCacheImpl($serviceLocator->get($options->getHydrationCache()));
     $config->setMetadataDriverImpl($serviceLocator->get($options->getDriver()));
     if ($namingStrategy = $options->getNamingStrategy()) {
         if (is_string($namingStrategy)) {
             if (!$serviceLocator->has($namingStrategy)) {
                 throw new InvalidArgumentException(sprintf('Naming strategy "%s" not found', $namingStrategy));
             }
             $config->setNamingStrategy($serviceLocator->get($namingStrategy));
         } else {
             $config->setNamingStrategy($namingStrategy);
         }
     }
     if ($repositoryFactory = $options->getRepositoryFactory()) {
         if (is_string($repositoryFactory)) {
             if (!$serviceLocator->has($repositoryFactory)) {
                 throw new InvalidArgumentException(sprintf('Repository factory "%s" not found', $repositoryFactory));
             }
             $config->setRepositoryFactory($serviceLocator->get($repositoryFactory));
         } else {
             $config->setRepositoryFactory($repositoryFactory);
         }
     }
     if ($entityListenerResolver = $options->getEntityListenerResolver()) {
         if ($entityListenerResolver instanceof EntityListenerResolver) {
             $config->setEntityListenerResolver($entityListenerResolver);
         } else {
             $config->setEntityListenerResolver($serviceLocator->get($entityListenerResolver));
         }
     }
     $this->setupDBALConfiguration($serviceLocator, $config);
     return $config;
 }
开发者ID:OnlineBidder,项目名称:onlineBidder,代码行数:60,代码来源:ConfigurationFactory.php

示例2: testSetCustomHydrationModes

 public function testSetCustomHydrationModes()
 {
     $this->configuration->addCustomHydrationMode('HydrationModeName', __CLASS__);
     $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName'));
     $this->configuration->setCustomHydrationModes(array('AnotherHydrationModeName' => __CLASS__));
     $this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName'));
     $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName'));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:8,代码来源:ConfigurationTest.php

示例3: loadDoctrineConfiguration

 public function loadDoctrineConfiguration(Application $app)
 {
     $app['db.orm.config'] = $app->share(function () use($app) {
         $cache = $app['db.orm.cache'];
         $config = new ORMConfiguration();
         $config->setMetadataCacheImpl($cache);
         $config->setQueryCacheImpl($cache);
         $chain = new MappingDriverChain();
         foreach ((array) $app['db.orm.entities'] as $entity) {
             switch ($entity['type']) {
                 case 'default':
                 case 'annotation':
                     $driver = $config->newDefaultAnnotationDriver((array) $entity['path'], false);
                     $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', $entity['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']);
         $config->addCustomHydrationMode('SimpleArrayHydrator', 'App\\Provider\\SimpleArrayHydrator');
         // автолоад прокси
         $proxyDir = $app['db.orm.proxies_dir'];
         $proxyNamespace = $app['db.orm.proxies_namespace'];
         Autoloader::register($proxyDir, $proxyNamespace);
         return $config;
     });
 }
开发者ID:arduanov,项目名称:silexTest,代码行数:42,代码来源:DoctrineORMServiceProvider.php

示例4: __invoke

 /**
  * {@inheritDoc}
  *
  * @return Configuration
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     /** @var $options \DoctrineORMModule\Options\Configuration */
     $options = $this->getOptions($container);
     $config = new Configuration();
     $config->setAutoGenerateProxyClasses($options->getGenerateProxies());
     $config->setProxyDir($options->getProxyDir());
     $config->setProxyNamespace($options->getProxyNamespace());
     $config->setEntityNamespaces($options->getEntityNamespaces());
     $config->setCustomDatetimeFunctions($options->getDatetimeFunctions());
     $config->setCustomStringFunctions($options->getStringFunctions());
     $config->setCustomNumericFunctions($options->getNumericFunctions());
     $config->setClassMetadataFactoryName($options->getClassMetadataFactoryName());
     foreach ($options->getNamedQueries() as $name => $query) {
         $config->addNamedQuery($name, $query);
     }
     foreach ($options->getNamedNativeQueries() as $name => $query) {
         $config->addNamedNativeQuery($name, $query['sql'], new $query['rsm']());
     }
     foreach ($options->getCustomHydrationModes() as $modeName => $hydrator) {
         $config->addCustomHydrationMode($modeName, $hydrator);
     }
     foreach ($options->getFilters() as $name => $class) {
         $config->addFilter($name, $class);
     }
     $config->setMetadataCacheImpl($container->get($options->getMetadataCache()));
     $config->setQueryCacheImpl($container->get($options->getQueryCache()));
     $config->setResultCacheImpl($container->get($options->getResultCache()));
     $config->setHydrationCacheImpl($container->get($options->getHydrationCache()));
     $config->setMetadataDriverImpl($container->get($options->getDriver()));
     if ($namingStrategy = $options->getNamingStrategy()) {
         if (is_string($namingStrategy)) {
             if (!$container->has($namingStrategy)) {
                 throw new InvalidArgumentException(sprintf('Naming strategy "%s" not found', $namingStrategy));
             }
             $config->setNamingStrategy($container->get($namingStrategy));
         } else {
             $config->setNamingStrategy($namingStrategy);
         }
     }
     if ($quoteStrategy = $options->getQuoteStrategy()) {
         if (is_string($quoteStrategy)) {
             if (!$container->has($quoteStrategy)) {
                 throw new InvalidArgumentException(sprintf('Quote strategy "%s" not found', $quoteStrategy));
             }
             $config->setQuoteStrategy($container->get($quoteStrategy));
         } else {
             $config->setQuoteStrategy($quoteStrategy);
         }
     }
     if ($repositoryFactory = $options->getRepositoryFactory()) {
         if (is_string($repositoryFactory)) {
             if (!$container->has($repositoryFactory)) {
                 throw new InvalidArgumentException(sprintf('Repository factory "%s" not found', $repositoryFactory));
             }
             $config->setRepositoryFactory($container->get($repositoryFactory));
         } else {
             $config->setRepositoryFactory($repositoryFactory);
         }
     }
     if ($entityListenerResolver = $options->getEntityListenerResolver()) {
         if ($entityListenerResolver instanceof EntityListenerResolver) {
             $config->setEntityListenerResolver($entityListenerResolver);
         } else {
             $config->setEntityListenerResolver($container->get($entityListenerResolver));
         }
     }
     $secondLevelCache = $options->getSecondLevelCache();
     if ($secondLevelCache->isEnabled()) {
         $regionsConfig = new RegionsConfiguration($secondLevelCache->getDefaultLifetime(), $secondLevelCache->getDefaultLockLifetime());
         foreach ($secondLevelCache->getRegions() as $regionName => $regionConfig) {
             if (isset($regionConfig['lifetime'])) {
                 $regionsConfig->setLifetime($regionName, $regionConfig['lifetime']);
             }
             if (isset($regionConfig['lock_lifetime'])) {
                 $regionsConfig->setLockLifetime($regionName, $regionConfig['lock_lifetime']);
             }
         }
         // As Second Level Cache caches queries results, we reuse the result cache impl
         $cacheFactory = new DefaultCacheFactory($regionsConfig, $config->getResultCacheImpl());
         $cacheFactory->setFileLockRegionDirectory($secondLevelCache->getFileLockRegionDirectory());
         $cacheConfiguration = new CacheConfiguration();
         $cacheConfiguration->setCacheFactory($cacheFactory);
         $cacheConfiguration->setRegionsConfiguration($regionsConfig);
         $config->setSecondLevelCacheEnabled();
         $config->setSecondLevelCacheConfiguration($cacheConfiguration);
     }
     if ($className = $options->getDefaultRepositoryClassName()) {
         $config->setDefaultRepositoryClassName($className);
     }
     $this->setupDBALConfiguration($container, $config);
     return $config;
 }
开发者ID:fanst1109,项目名称:doctrine-orm-module,代码行数:98,代码来源:ConfigurationFactory.php

示例5: setCustomHydrators

 /**
  * @param array         $settings
  * @param Configuration $configuration
  */
 protected function setCustomHydrators(array $settings = [], Configuration $configuration)
 {
     foreach (array_get($settings, 'hydrators', []) as $mode => $hydrator) {
         $configuration->addCustomHydrationMode($mode, $hydrator);
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:10,代码来源:EntityManagerFactory.php

示例6: setupCustomFunctions

 protected function setupCustomFunctions(Configuration $config, $spec)
 {
     foreach ($spec['custom_hydration_modes'] as $name => $classname) {
         $config->addCustomHydrationMode($name, $classname);
     }
     foreach ($spec['custom_datetime_functions'] as $name => $classname) {
         $config->addCustomDatetimeFunction($name, $classname);
     }
     foreach ($spec['custom_numeric_functions'] as $name => $classname) {
         $config->addCustomNumericFunction($name, $classname);
     }
     foreach ($spec['custom_string_functions'] as $name => $classname) {
         $config->addCustomStringFunction($name, $classname);
     }
     foreach ($spec['filters'] as $name => $classname) {
         $config->addFilter($name, $classname);
     }
 }
开发者ID:radnan,项目名称:rdn-doctrine,代码行数:18,代码来源:EntityManagerLoader.php


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