Exemplo n.º 1
0
 /**
  * @return \FS\SolrBundle\Doctrine\Mapper\MetaInformationFactory
  */
 private function setupMetaInformationFactory()
 {
     $ormConfiguration = new \Doctrine\ORM\Configuration();
     $ormConfiguration->addEntityNamespace('FSTest:ValidTestEntity', 'FS\\SolrBundle\\Tests\\Doctrine\\Mapper');
     $ormConfiguration->addEntityNamespace('FSTest:EntityCore0', 'FS\\SolrBundle\\Tests\\Doctrine\\Mapper');
     $ormConfiguration->addEntityNamespace('FSTest:EntityCore1', 'FS\\SolrBundle\\Tests\\Doctrine\\Mapper');
     $knowNamespaces = new \FS\SolrBundle\Doctrine\ClassnameResolver\KnownNamespaceAliases();
     $knowNamespaces->addEntityNamespaces($ormConfiguration);
     $classnameResolver = new \FS\SolrBundle\Doctrine\ClassnameResolver\ClassnameResolver($knowNamespaces);
     $metaFactory = new \FS\SolrBundle\Doctrine\Mapper\MetaInformationFactory();
     $metaFactory->setClassnameResolver($classnameResolver);
     return $metaFactory;
 }
Exemplo n.º 2
0
 protected function setUp()
 {
     if (!class_exists('\\Doctrine\\ORM\\Configuration')) {
         $this->markTestSkipped('Doctrine is not available');
     }
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('Intaro\\HStore\\Tests\\Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/Entities'));
     $config->addEntityNamespace('E', 'Intaro\\HStore\\Tests\\Doctrine\\Entities');
     $config->setCustomStringFunctions(array('contains' => 'Intaro\\HStore\\Doctrine\\Query\\ContainsFunction', 'defined' => 'Intaro\\HStore\\Doctrine\\Query\\DefinedFunction', 'existsAny' => 'Intaro\\HStore\\Doctrine\\Query\\ExistsAnyFunction', 'fetchval' => 'Intaro\\HStore\\Doctrine\\Query\\FetchvalFunction', 'hstoreDifference' => 'Intaro\\HStore\\Doctrine\\Query\\HstoreDifferenceFunction'));
     $this->entityManager = \Doctrine\ORM\EntityManager::create(array('driver' => 'pdo_sqlite', 'memory' => true), $config);
 }
Exemplo n.º 3
0
 /**
  * Initialize ORM Configuration.
  *
  * @param array $config ORM EntityManager configuration.
  *
  * @return Doctrine\ORM\Configuration
  */
 private function startORMConfiguration(array $config = array())
 {
     $configClass = $config['configurationClass'];
     $configuration = new $configClass();
     $configuration = new \Doctrine\ORM\Configuration();
     // Entity Namespaces configuration
     foreach ($config['entityNamespaces'] as $alias => $namespace) {
         $configuration->addEntityNamespace($alias, $namespace);
     }
     // Proxy configuration
     $configuration->setAutoGenerateProxyClasses(!in_array($config['proxy']['autoGenerateClasses'], array("0", "false", false)));
     $configuration->setProxyNamespace($config['proxy']['namespace']);
     $configuration->setProxyDir($config['proxy']['dir']);
     // Cache configuration
     $configuration->setMetadataCacheImpl($this->getCacheInstance($config['metadataCache']));
     $configuration->setResultCacheImpl($this->getCacheInstance($config['resultCache']));
     $configuration->setQueryCacheImpl($this->getCacheInstance($config['queryCache']));
     // Metadata configuration
     $configuration->setMetadataDriverImpl($this->startORMMetadata($config['metadataDrivers']));
     // DQL Functions configuration
     $dqlFunctions = $config['DQLFunctions'];
     foreach ($dqlFunctions['datetime'] as $name => $className) {
         $configuration->addCustomDatetimeFunction($name, $className);
     }
     foreach ($dqlFunctions['numeric'] as $name => $className) {
         $configuration->addCustomNumericFunction($name, $className);
     }
     foreach ($dqlFunctions['string'] as $name => $className) {
         $configuration->addCustomStringFunction($name, $className);
     }
     return $configuration;
 }
Exemplo n.º 4
0
 /**
  * 
  * Conecta el manejador con los parametros especificados en la configuracion de Raptor
  */
 public function connect()
 {
     $op = $this->app->getConfigurationLoader()->getOptions();
     if (isset($op['options']['database'])) {
         $this->options = $op['options']['database'];
         $this->options['bundles'] = $op['bundles'];
         $this->options['specifications'] = $op['specifications'];
     } else {
         $this->state = false;
     }
     $this->registerClassLoader();
     $config = new \Doctrine\ORM\Configuration();
     if (!file_exists(\Raptor\Core\Location::get(\Raptor\Core\Location::CACHE) . '/d0374123/Proxies')) {
         mkdir(\Raptor\Core\Location::get(\Raptor\Core\Location::CACHE) . '/d0374123/Proxies', 0777, true);
     }
     $config->setProxyDir(\Raptor\Core\Location::get(\Raptor\Core\Location::CACHE) . '/d0374123/Proxies');
     $config->setProxyNamespace('Proxies');
     //        $config->setAutoGenerateProxyClasses(($this->app->getMode() == "development"));
     $config->setAutoGenerateProxyClasses(true);
     $annotations = array();
     $definitions = new ItemList($this->options['specifications']);
     $definitions->each(function ($key, $value) use(&$config, &$annotations) {
         $config->addEntityNamespace($key, $value['namespace'] . '\\Model\\Entity');
         $annotations[] = $value['location'];
     });
     $driverImpl = $config->newDefaultAnnotationDriver($annotations);
     $this->annotations = $annotations;
     $config->setMetadataDriverImpl($driverImpl);
     if (true) {
         $cache = new \Doctrine\Common\Cache\ArrayCache();
     } else {
         $cache = new \Doctrine\Common\Cache\ApcCache();
     }
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $connectionOptions = array('driver' => $this->options['driver'], 'dbname' => $this->options['dbname'], 'user' => $this->options['user'], 'password' => $this->options['password'], 'port' => $this->options['port'], 'host' => $this->options['host']);
     $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
     $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)));
     $this->entityManager = $em;
     $this->state = true;
 }
Exemplo n.º 5
0
 /**
  * Initialize ORM Configuration.
  *
  * @param array $config ORM EntityManager configuration.
  *
  * @return \Doctrine\ORM\Configuration
  */
 private function startORMConfiguration(array $config = array())
 {
     $configClass = $config['configurationClass'];
     $configuration = new $configClass();
     $configuration = new \Doctrine\ORM\Configuration();
     // Entity Namespaces configuration
     foreach ($config['entityNamespaces'] as $alias => $namespace) {
         $configuration->addEntityNamespace($alias, $namespace);
     }
     // Proxy configuration
     $configuration->setAutoGenerateProxyClasses($config['proxy']['autoGenerateClasses'] === true || !in_array($config['proxy']['autoGenerateClasses'], array("0", "false", false)));
     $configuration->setProxyNamespace($config['proxy']['namespace']);
     $configuration->setProxyDir($config['proxy']['dir']);
     // Cache configuration
     $configuration->setMetadataCacheImpl($this->getCacheInstance($config['metadataCache']));
     $configuration->setResultCacheImpl($this->getCacheInstance($config['resultCache']));
     $configuration->setQueryCacheImpl($this->getCacheInstance($config['queryCache']));
     // SecondLevelCache configuration
     if (isset($config['secondLevelCache']) && method_exists($configuration, 'setSecondLevelCacheEnabled')) {
         $configuration->setSecondLevelCacheEnabled($config['secondLevelCache']['enabled'] === true || !in_array($config['secondLevelCache']['enabled'], array("0", "false", false)));
         if ($configuration->isSecondLevelCacheEnabled()) {
             $regionsConfigurationClass = $config['secondLevelCache']['regionsConfigurationClass'];
             $factoryClass = $config['secondLevelCache']['cacheFactoryClass'];
             $factory = new $factoryClass(new $regionsConfigurationClass(), $this->getCacheInstance($config['secondLevelCache']['cache']));
             $configuration->getSecondLevelCacheConfiguration()->setCacheFactory($factory);
             if (isset($config['secondLevelCache']['loggerClass'])) {
                 $loggerClass = $config['secondLevelCache']['loggerClass'];
                 $configuration->getSecondLevelCacheConfiguration()->setCacheLogger(new $loggerClass());
             }
         }
     }
     // Metadata configuration
     $configuration->setMetadataDriverImpl($this->startORMMetadata($config['metadataDrivers']));
     //Filters http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html#configuration
     if (isset($config['filters'])) {
         foreach ($config['filters'] as $name => $className) {
             $configuration->addFilter($name, $className);
         }
     }
     // DQL Functions configuration
     $dqlFunctions = $config['DQLFunctions'];
     foreach ($dqlFunctions['datetime'] as $name => $className) {
         $configuration->addCustomDatetimeFunction($name, $className);
     }
     foreach ($dqlFunctions['numeric'] as $name => $className) {
         $configuration->addCustomNumericFunction($name, $className);
     }
     foreach ($dqlFunctions['string'] as $name => $className) {
         $configuration->addCustomStringFunction($name, $className);
     }
     // Repository Class configuration
     if (isset($config['defaultRepositoryClass'])) {
         $configuration->setDefaultRepositoryClassName($config['defaultRepositoryClass']);
     }
     // Naming strategy for ORM
     $configuration->setNamingStrategy(new $config['namingStrategyClass']());
     // proxy dirs
     $configuration->setProxyDir(APPLICATION_PATH . '/data/Doctrine2/Proxy');
     $configuration->setProxyNamespace('Doctrine2\\Proxy');
     return $configuration;
 }