setProxyDir() public method

Sets the directory where Doctrine generates any necessary proxy class files.
public setProxyDir ( string $dir )
$dir string
 /**
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return object
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $manifest = $serviceLocator->get('manifest');
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB(self::DEFAULT_DB);
     $config->setMetadataCacheImpl(new ArrayCache());
     //create driver chain
     $chain = new MappingDriverChain();
     foreach ($manifest['documents'] as $namespace => $path) {
         $driver = new AnnotationDriver(new AnnotationReader(), $path);
         $chain->addDriver($driver, $namespace);
     }
     $config->setMetadataDriverImpl($chain);
     //register filters
     foreach ($manifest['filters'] as $name => $class) {
         $config->addFilter($name, $class);
     }
     //create event manager
     $eventManager = new EventManager();
     foreach ($manifest['subscribers'] as $subscriber) {
         $eventManager->addEventSubscriber($serviceLocator->get($subscriber));
     }
     //register annotations
     AnnotationRegistry::registerLoader(function ($className) {
         return class_exists($className);
     });
     $conn = new Connection(null, array(), $config);
     return DocumentManager::create($conn, $config, $eventManager);
 }
 /**
  * Called on framework init.
  */
 public function register()
 {
     // Note:    If you'd like to use annotation, XML or YAML mappings, simply bind another
     //          implementation of this interface in your project and we'll use it! :)
     $this->app->singleton('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver', function (Application $app) {
         return new ConfigMapping(config('mongodb.mappings'));
     });
     $this->app->singleton('Doctrine\\MongoDB\\Configuration', function (Application $app) {
         $config = new Configuration();
         $config->setProxyDir(storage_path('cache/MongoDbProxies'));
         $config->setProxyNamespace('MongoDbProxy');
         $config->setHydratorDir(storage_path('cache/MongoDbHydrators'));
         $config->setHydratorNamespace('MongoDbHydrator');
         $config->setDefaultDB(config('mongodb.default_db', 'laravel'));
         // Request whatever mapping driver is bound to the interface.
         $config->setMetadataDriverImpl($app->make('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver'));
         return $config;
     });
     $this->app->singleton('MongoClient', function (Application $app) {
         return new MongoClient(config('mongodb.host', 'localhost'));
     });
     $this->app->singleton('Doctrine\\MongoDB\\Connection', function (Application $app) {
         return new Connection($app->make('MongoClient'));
     });
     // Because of our bindings above, this one's actually a cinch!
     $this->app->singleton('Doctrine\\ODM\\MongoDB\\DocumentManager', function (Application $app) {
         return DocumentManager::create($app->make('Doctrine\\MongoDB\\Connection'), $app->make('Doctrine\\MongoDB\\Configuration'));
     });
 }
Example #3
0
    public function setUp()
    {
        $config = new Configuration();

        $config->setProxyDir(__DIR__ . '/../../../../Proxies');
        $config->setProxyNamespace('Proxies');

        $config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
        $config->setHydratorNamespace('Hydrators');

        $config->setDefaultDB('doctrine_odm_tests');

        /*
        $config->setLoggerCallable(function(array $log) {
            print_r($log);
        });
        $config->setMetadataCacheImpl(new ApcCache());
        */

        $reader = new AnnotationReader();
        $reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\');
        $this->annotationDriver = new AnnotationDriver($reader, __DIR__ . '/../../../../Documents');
        $config->setMetadataDriverImpl($this->annotationDriver);

        $conn = new Connection(null, array(), $config);
        $this->dm = DocumentManager::create($conn, $config);
        $this->uow = $this->dm->getUnitOfWork();
    }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('odm.documentmanager', function ($app) {
         $conn = Config::get('laravel-odm::connection');
         return DocumentManager::create(new Connection($conn['server'], $conn['options']), App::make('odm.config'));
     });
     $this->app->bind('odm.config', function ($app) {
         $conn = Config::get('laravel-odm::connection');
         $dir = Config::get('laravel-odm::dir');
         $config = new Configuration();
         $config->setProxyDir($dir['proxy']);
         $config->setProxyNamespace('Proxies');
         $config->setHydratorDir($dir['hydrator']);
         $config->setHydratorNamespace('Hydrators');
         $config->setMetadataDriverImpl(App::make('odm.annotation'));
         $config->setDefaultDB($conn['options']['db']);
         return $config;
     });
     $this->app->bind('odm.annotation', function ($app) {
         $dir = Config::get('laravel-odm::dir');
         AnnotationDriver::registerAnnotationClasses();
         $reader = new AnnotationReader();
         return new AnnotationDriver($reader, $dir['document']);
     });
 }
Example #5
0
 protected function getDocumentManager()
 {
     if (is_null($this->_documentManager)) {
         $options = $this->getOptions();
         // ODM Class
         $classLoader = new ClassLoader('Doctrine\\ODM\\MongoDB', APPLICATION_PATH . '/../library');
         $classLoader->register();
         // Common Class
         $classLoader = new ClassLoader('Doctrine\\Common', APPLICATION_PATH . '/../library');
         $classLoader->register();
         // MongoDB Class
         $classLoader = new ClassLoader('Doctrine\\MongoDB', APPLICATION_PATH . '/../library');
         $classLoader->register();
         $classLoader = new ClassLoader('Documents', $options['documentPath']);
         $classLoader->register();
         $config = new Configuration();
         $config->setProxyDir($options['proxyDir']);
         $config->setProxyNamespace($options['proxyNamespace']);
         $config->setHydratorDir($options['hydratorDir']);
         $config->setHydratorNamespace($options['hydratorNamespace']);
         $reader = new AnnotationReader();
         AnnotationDriver::registerAnnotationClasses();
         $config->setMetadataDriverImpl(new AnnotationDriver($reader, $options['documentPath']));
         $config->setDefaultDB($options['dbname']);
         $this->_documentManager = DocumentManager::create(new Connection($options['server']), $config);
     }
     return $this->_documentManager;
 }
 /**
  * Datasource constructor, creates the Configuration, Connection and DocumentManager objects
  *
  * ### You can pass the following configuration options
  *
  *	- server: name of the server that will be used to connect to Mongo (default: `localhost`)
  *	- database: name of the database to use when connecting to Mongo (default: `cake`)
  *	- documentPaths: array containing a list of full path names where Document classes can be located (default: `App::path('Model')`)
  *	- proxyDir: full path to the directory that will contain the generated proxy classes for each document (default: `TMP . 'cache'`)
  *	- proxyNamespace: string representing the namespace the proxy classes will reside in (default: `Proxies`)
  *	- hydratorDir: directory well the hydrator classes will be generated in (default: `TMP . 'cache'`)
  *	- hydratorNamespace:  string representing the namespace the hydrator classes will reside in (default: `Hydrators`)
  *
  * @param arary $config
  * @param boolean $autoConnect whether this object should attempt connection on creation
  * @throws MissingConnectionException if it was not possible to connect to MongoDB
  */
 public function __construct($config = array(), $autoConnect = true)
 {
     $modelPaths = $this->_cleanupPaths(App::path('Model'));
     $this->_baseConfig = array('proxyDir' => TMP . 'cache', 'proxyNamespace' => 'Proxies', 'hydratorDir' => TMP . 'cache', 'hydratorNamespace' => 'Hydrators', 'server' => 'localhost', 'database' => 'cake', 'documentPaths' => $modelPaths, 'prefix' => null);
     foreach (CakePlugin::loaded() as $plugin) {
         $this->_baseConfig['documentPaths'] = array_merge($this->_baseConfig['documentPaths'], $this->_cleanupPaths(App::path('Model', $plugin)));
     }
     parent::__construct($config);
     extract($this->config, EXTR_OVERWRITE);
     $configuration = new Configuration();
     $configuration->setProxyDir($proxyDir);
     $configuration->setProxyNamespace($proxyNamespace);
     $configuration->setHydratorDir($hydratorDir);
     $configuration->setHydratorNamespace($hydratorNamespace);
     $configuration->setDefaultDB($database);
     $configuration->setMetadataDriverImpl($this->_getMetadataReader($documentPaths));
     if (Configure::read('debug') === 0) {
         $configuration->setAutoGenerateHydratorClasses(false);
         $configuration->setAutoGenerateProxyClasses(false);
         $configuration->setMetadataCacheImpl(new ApcCache());
     }
     $this->configuration = $configuration;
     $this->connection = new Connection($server, array(), $configuration);
     $this->documentManager = DocumentManager::create($this->connection, $configuration);
     $this->documentManager->getEventManager()->addEventListener(array(Events::prePersist, Events::preUpdate, Events::preRemove, Events::postPersist, Events::postUpdate, Events::postRemove), $this);
     try {
         if ($autoConnect) {
             $this->connect();
         }
     } catch (Exception $e) {
         throw new MissingConnectionException(array('class' => get_class($this)));
     }
     $this->setupLogger();
 }
Example #7
0
 /**
  * Connect to MongoDb
  * @return DocumentManager
  */
 public function _initDb()
 {
     $container = $this;
     $this['documentManager'] = $this->share(function () use($container) {
         $dbConfigs = $container['configs']['database'];
         try {
             if (empty($dbConfigs['user'])) {
                 $connection_url = "mongodb://{$dbConfigs['host']}:{$dbConfigs['port']}/{$dbConfigs['name']}";
             } else {
                 $connection_url = "mongodb://{$dbConfigs['user']}:{$dbConfigs['passwd']}@{$dbConfigs['host']}:{$dbConfigs['port']}/{$dbConfigs['name']}";
             }
             AnnotationDriver::registerAnnotationClasses();
             $config = new Configuration();
             $config->setProxyDir(BIN_PATH . '/src/Blueridge/Documents/Proxies');
             $config->setProxyNamespace('Proxies');
             $config->setHydratorDir(BIN_PATH . '/src/Blueridge/Documents/Hydrators');
             $config->setHydratorNamespace('Hydrators');
             $config->setMetadataDriverImpl(AnnotationDriver::create(BIN_PATH . '/src/Blueridge/Documents'));
             $config->setDefaultDB($dbConfigs['name']);
             return DocumentManager::create(new Connection($connection_url), $config);
         } catch (Exception $e) {
             error_log($e->getMessage());
         }
     });
 }
 public function setUp()
 {
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('Proxies');
     $reader = new AnnotationReader();
     $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
     $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
     $this->dm = DocumentManager::create(new Mongo(), $config);
     $currencies = array('USD' => 1, 'EURO' => 1.7, 'JPN' => 0.0125);
     foreach ($currencies as $name => &$multiplier) {
         $multiplier = new Currency($name, $multiplier);
         $this->dm->persist($multiplier);
     }
     $product = new ConfigurableProduct('T-Shirt');
     $product->addOption(new Option('small', new Money(12.99, $currencies['USD']), new StockItem('T-shirt Size S', new Money(9.99, $currencies['USD']), 15)));
     $product->addOption(new Option('medium', new Money(14.99, $currencies['USD']), new StockItem('T-shirt Size M', new Money(11.99, $currencies['USD']), 15)));
     $product->addOption(new Option('large', new Money(17.99, $currencies['USD']), new StockItem('T-shirt Size L', new Money(13.99, $currencies['USD']), 15)));
     $this->dm->persist($product);
     $this->dm->flush();
     foreach ($currencies as $currency) {
         $this->dm->detach($currency);
     }
     $this->dm->detach($product);
     unset($currencies, $product);
 }
 /**
  *
  * @param  \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return object
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $manifest = $serviceLocator->get('manifest');
     $extension = $serviceLocator->get('extension.odmcore');
     $config = new Configuration();
     $config->setProxyDir($extension->getProxyDir());
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir($extension->getHydratorDir());
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB($extension->getDefaultDb());
     $config->setClassMetadataFactoryName($extension->getClassMetadataFactory());
     $config->setMetadataCacheImpl(new ArrayCache());
     //create driver chain
     $chain = new MappingDriverChain();
     foreach ($manifest->getModels() as $namespace => $path) {
         $driver = new AnnotationDriver(new AnnotationReader(), $path);
         $chain->addDriver($driver, $namespace);
     }
     $config->setMetadataDriverImpl($chain);
     //register filters
     foreach ($extension->getFilters() as $name => $class) {
         $config->addFilter($name, $class);
     }
     //create event manager
     $eventManager = new EventManager();
     foreach ($manifest->getSubscribers() as $subscriber) {
         $eventManager->addEventSubscriber($serviceLocator->get($subscriber));
     }
     //register annotations
     AnnotationRegistry::registerLoader(function ($className) {
         return class_exists($className);
     });
     $conn = new Connection(null, array(), $config);
     return ModelManager::create($conn, $config, $eventManager);
 }
 public function setUp()
 {
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(__DIR__ . '/../../../../../Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB('doctrine_odm_tests');
     $reader = new AnnotationReader();
     $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
     $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
     $this->dm = DocumentManager::create(new Connection(), $config);
     $currencies = array('USD' => 1, 'EURO' => 1.7, 'JPN' => 0.0125);
     foreach ($currencies as $name => &$multiplier) {
         $multiplier = new Currency($name, $multiplier);
         $this->dm->persist($multiplier);
     }
     $stockItems = array(new StockItem('stock_item_0', new Money(9.99 * 0 + 5, $currencies['USD']), 5), new StockItem('stock_item_1', new Money(9.99 * 1 + 5, $currencies['USD']), 15 * 1 - 4), new StockItem('stock_item_2', new Money(9.99 * 2 + 5, $currencies['USD']), 15 * 2 - 4), new StockItem('stock_item_3', new Money(9.99 * 3 + 5, $currencies['USD']), 15 * 3 - 4), new StockItem('stock_item_4', new Money(9.99 * 4 + 5, $currencies['USD']), 15 * 4 - 4), new StockItem('stock_item_5', new Money(9.99 * 5 + 5, $currencies['USD']), 15 * 5 - 4), new StockItem('stock_item_6', new Money(9.99 * 6 + 5, $currencies['USD']), 15 * 6 - 4), new StockItem('stock_item_7', new Money(9.99 * 7 + 5, $currencies['USD']), 15 * 7 - 4), new StockItem('stock_item_8', new Money(9.99 * 8 + 5, $currencies['USD']), 15 * 8 - 4), new StockItem('stock_item_9', new Money(9.99 * 9 + 5, $currencies['USD']), 15 * 9 - 4));
     $options = array(new Option('option_0', new Money(13.99, $currencies['USD']), $stockItems[0]), new Option('option_1', new Money(14.99, $currencies['USD']), $stockItems[1]), new Option('option_2', new Money(15.99, $currencies['USD']), $stockItems[2]), new Option('option_3', new Money(16.99, $currencies['USD']), $stockItems[3]), new Option('option_4', new Money(17.99, $currencies['USD']), $stockItems[4]), new Option('option_5', new Money(18.99, $currencies['USD']), $stockItems[5]), new Option('option_6', new Money(19.99, $currencies['USD']), $stockItems[6]), new Option('option_7', new Money(20.99, $currencies['USD']), $stockItems[7]), new Option('option_8', new Money(21.99, $currencies['USD']), $stockItems[8]), new Option('option_9', new Money(22.99, $currencies['USD']), $stockItems[9]));
     $products = array(new ConfigurableProduct('product_0'), new ConfigurableProduct('product_1'), new ConfigurableProduct('product_2'), new ConfigurableProduct('product_3'), new ConfigurableProduct('product_4'), new ConfigurableProduct('product_5'), new ConfigurableProduct('product_6'), new ConfigurableProduct('product_7'), new ConfigurableProduct('product_8'), new ConfigurableProduct('product_9'));
     $products[0]->addOption($options[0]);
     $products[0]->addOption($options[4]);
     $products[0]->addOption($options[6]);
     $products[1]->addOption($options[1]);
     $products[1]->addOption($options[2]);
     $products[1]->addOption($options[5]);
     $products[1]->addOption($options[7]);
     $products[1]->addOption($options[8]);
     $products[2]->addOption($options[3]);
     $products[2]->addOption($options[5]);
     $products[2]->addOption($options[7]);
     $products[2]->addOption($options[9]);
     $products[3]->addOption($options[0]);
     $products[3]->addOption($options[1]);
     $products[3]->addOption($options[2]);
     $products[3]->addOption($options[3]);
     $products[3]->addOption($options[4]);
     $products[3]->addOption($options[5]);
     $products[4]->addOption($options[4]);
     $products[4]->addOption($options[7]);
     $products[4]->addOption($options[2]);
     $products[4]->addOption($options[8]);
     $products[5]->addOption($options[9]);
     $products[6]->addOption($options[7]);
     $products[6]->addOption($options[8]);
     $products[6]->addOption($options[9]);
     $products[7]->addOption($options[4]);
     $products[7]->addOption($options[5]);
     $products[8]->addOption($options[2]);
     $products[9]->addOption($options[4]);
     $products[9]->addOption($options[3]);
     $products[9]->addOption($options[7]);
     foreach ($products as $product) {
         $this->dm->persist($product);
     }
     $this->dm->flush();
     $this->dm->clear();
 }
Example #11
0
 /**
  * @return DocumentManager
  */
 protected function createDocumentManager($server)
 {
     AnnotationDriver::registerAnnotationClasses();
     $configuration = new Configuration();
     $configuration->setProxyDir(sys_get_temp_dir());
     $configuration->setProxyNamespace('Proxies');
     $configuration->setHydratorDir(sys_get_temp_dir());
     $configuration->setHydratorNamespace('Hydrators');
     $configuration->setMetadataDriverImpl(AnnotationDriver::create());
     return DocumentManager::create(new Connection($server), $configuration);
 }
Example #12
0
File: Hive.php Project: 100hz/hive
 /**
  * Creates the doctrine document mananger for working on the database
  *
  * @return DocumentManager
  */
 protected function createDocumentManager()
 {
     AnnotationDriver::registerAnnotationClasses();
     $configuration = new Configuration();
     $configuration->setProxyDir($this->configuration['doctrine']['proxyDir']);
     $configuration->setProxyNamespace($this->configuration['doctrine']['proxyNamespace']);
     $configuration->setHydratorDir($this->configuration['doctrine']['hydratorDir']);
     $configuration->setHydratorNamespace($this->configuration['doctrine']['hydratorNamespace']);
     $configuration->setMetadataDriverImpl(AnnotationDriver::create());
     return DocumentManager::create(new Connection($this->configuration['doctrine']['connection']['server']), $configuration);
 }
 /**
  *
  * @param array $config
  * @return DocumentManager
  */
 public static function createDocumentManager($config, Container $container)
 {
     $configuration = new Configuration();
     if (is_null($config['eventManager'])) {
         $evm = new EventManager();
     } else {
         $evm = $config['eventManager'];
     }
     $configuration->setProxyDir($config['proxyDir']);
     $configuration->setProxyNamespace($config['proxyNamespace']);
     $configuration->setHydratorDir($config['hydratorDir']);
     $configuration->setHydratorNamespace($config['hydratorNamespace']);
     $configuration->setAutoGenerateHydratorClasses($config['autoGenerateHydratorClasses']);
     $configuration->setAutoGenerateProxyClasses($config['autoGenerateProxyClasses']);
     if (isset($config['metaDataCache'])) {
         $metadataCache = $config['metaDataCache'];
     } else {
         $metadataCache = new $config['metaDataCacheClass']();
         $metadataCache->setNamespace($config['cachePrefix']);
     }
     $configuration->setMetadataCacheImpl($metadataCache);
     AnnotationDriver::registerAnnotationClasses();
     $reader = new AnnotationReader();
     if ($config['cacheAnnotations'] == TRUE) {
         $reader = new CachedReader($reader, $metadataCache, $config['debug']);
     }
     if ($config['indexAnnotations'] == TRUE) {
         $reader = new IndexedReader($reader);
     }
     if (class_exists(\Gedmo\DoctrineExtensions::class)) {
         \Gedmo\DoctrineExtensions::registerAnnotations();
         $configuration->addFilter('soft-deleteable', \Gedmo\SoftDeleteable\Filter\ODM\SoftDeleteableFilter::class);
         foreach ($config['listeners'] as $listenerName => $enabled) {
             if ($enabled) {
                 $listener = self::configureListener($listenerName, $reader);
                 $evm->addEventSubscriber($listener);
             }
         }
     }
     $driverImpl = new AnnotationDriver($reader, $config['documentsDir']);
     $configuration->setMetadataDriverImpl($driverImpl);
     $configuration->setDefaultDB($config['dbname']);
     $logger = new Logger($config['logger'], $config['loggerPrefix']);
     $configuration->setLoggerCallable([$logger, 'logQuery']);
     $mongo = new MongoClient($config['uri'], $config['mongoOptions']);
     $connection = new Connection($mongo);
     $dm = DocumentManager::create($connection, $configuration, $evm);
     foreach ($config['filters'] as $filter => $enabled) {
         if ($enabled) {
             $dm->getFilterCollection()->enable($filter);
         }
     }
     return $dm;
 }
 /**
  * @return EntityManager
  */
 public static function createTestDocumentManager($paths = array())
 {
     $config = new Configuration();
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setHydratorDir(\sys_get_temp_dir());
     $config->setProxyNamespace('GenemuFormBundleTests\\Doctrine');
     $config->setHydratorNamespace('GenemuFormBundleTests\\Doctrine');
     $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), $paths));
     $config->setMetadataCacheImpl(new ArrayCache());
     return DocumentManager::create(new Connection(), $config);
 }
 /**
  * Get configuration of database 
  * @param String $dataBaseName
  * @return array
  */
 private function getConn()
 {
     AnnotationDriver::registerAnnotationClasses();
     $conn = (require self::$dir);
     $dataBase = (object) $conn['mongodb'];
     $config = new Configuration();
     $config->setProxyDir($dataBase->proxy['dir']);
     $config->setProxyNamespace($dataBase->proxy['namespace']);
     $config->setHydratorDir($dataBase->hydrator['dir']);
     $config->setHydratorNamespace($dataBase->hydrator['namespace']);
     $config->setMetadataDriverImpl(AnnotationDriver::create($dataBase->entityDir));
 }
 /**
  * @param array $params
  * @return mixed
  */
 public function produce(array $params = array())
 {
     $configuration = new Configuration();
     $configuration->setProxyDir($params['proxy_dir']);
     $configuration->setProxyNamespace($params['proxy_namespace']);
     $configuration->setHydratorDir($params['hydrator_dir']);
     $configuration->setHydratorNamespace($params['hydrator_namespace']);
     $configuration->setDefaultDB($params['default_db']);
     $configuration->setMetadataDriverImpl(AnnotationDriver::create($params['document_dir']));
     AnnotationDriver::registerAnnotationClasses();
     return $configuration;
 }
Example #17
0
 public function setUp()
 {
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(__DIR__ . '/../../../../../Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $reader = new AnnotationReader();
     $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
     $config->setDefaultDB('testing');
     $this->dm = DocumentManager::create(new Connection(), $config);
 }
 /**
  * @return ObjectManager
  */
 protected function createObjectManager()
 {
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../proxies');
     $config->setProxyNamespace('Proxy');
     $config->setHydratorDir(__DIR__ . '/../hydrators');
     $config->setHydratorNamespace('Hydrator');
     $fileLocator = new SymfonyFileLocator(array(__DIR__ . '/../../metadata' => 'XApi\\Repository\\Api\\Mapping'), '.mongodb.xml');
     $driver = new XmlDriver($fileLocator);
     $config->setMetadataDriverImpl($driver);
     return DocumentManager::create(new Connection(), $config);
 }
 public function __construct()
 {
     AnnotationDriver::registerAnnotationClasses();
     $config = new Configuration();
     $config->setProxyDir(app_path() . '/storage/cache/Doctrine/Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(app_path() . '/storage/cache/Doctrine/Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setMetadataDriverImpl(AnnotationDriver::create(app_path() . '/app/Model/Entity'));
     $config->setDefaultDB(config('database.db_name'));
     parent::__construct(new Connection(\Config::get('database.host')), $config);
 }
Example #20
0
 public function setUp()
 {
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setEnvironment('test');
     $config->setDefaultDB($this->defaultDB);
     $reader = new AnnotationReader();
     $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
     $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
     $this->dm = DocumentManager::create(new Mongo(), $config);
 }
 public function __construct($cacheDir)
 {
     $config = new Configuration();
     $config->setProxyDir($cacheDir);
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir($cacheDir);
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB(DB_NAME);
     $reader = new IndexedReader(new AnnotationReader());
     $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/../../Models'));
     $connection = new \Doctrine\MongoDB\Connection(DoctrineNativeConnect::GetInstance()->mongo, array(), $config);
     $this->Doctrinemodel = DocumentManager::create($connection, $config);
 }
Example #22
0
 protected function getConfiguration()
 {
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB(DOCTRINE_MONGODB_DATABASE);
     $config->setMetadataDriverImpl($this->createMetadataDriverImpl());
     $config->addFilter('testFilter', 'Doctrine\\ODM\\MongoDB\\Tests\\Query\\Filter\\Filter');
     $config->addFilter('testFilter2', 'Doctrine\\ODM\\MongoDB\\Tests\\Query\\Filter\\Filter');
     return $config;
 }
Example #23
0
 protected function getTestDocumentManager($metadataDriver = null)
 {
     if ($metadataDriver === null) {
         $metadataDriver = new MetadataDriverMock();
     }
     $mongoMock = new ConnectionMock();
     $config = new \Doctrine\ODM\MongoDB\Configuration();
     $config->setProxyDir(__DIR__ . '/../../Proxies');
     $config->setProxyNamespace('Doctrine\\ODM\\MongoDB\\Tests\\Proxies');
     $eventManager = new EventManager();
     $mockDriver = new MetadataDriverMock();
     $config->setMetadataDriverImpl($metadataDriver);
     return DocumentManagerMock::create($mongoMock, $config, $eventManager);
 }
Example #24
0
 public function setUp()
 {
     $this->app()->bind(EntityManagerInterface::class, function () {
         $config = new Configuration();
         $config->setProxyDir(__DIR__ . '/Entities/Proxies');
         $config->setProxyNamespace('Tests\\Proxy');
         $config->setHydratorDir(__DIR__ . '/Entities/Hydrators');
         $config->setHydratorNamespace('Tests\\Hydrators');
         $config->setDefaultDB('test-base-api-php');
         $config->setMetadataDriverImpl(AnnotationDriver::create(__DIR__ . '/Entities/Stubs'));
         $connection = new Connection();
         AnnotationDriver::registerAnnotationClasses();
         return EntityManager::create($connection, $config);
     });
 }
 public function register(Application $app)
 {
     $app['mongo.dm'] = $app->share(function () {
         AnnotationDriver::registerAnnotationClasses();
         $config = new Configuration();
         $config->setDefaultDB('descartemap');
         $config->setProxyDir(ROOT . '/var/proxies');
         $config->setProxyNamespace('Proxies');
         $config->setHydratorDir(ROOT . '/var/hydrators');
         $config->setHydratorNamespace('Hydrators');
         $config->setMetadataDriverImpl(AnnotationDriver::create(ROOT . '/var/cache/'));
         $dm = DocumentManager::create(new Connection(), $config);
         return $dm;
     });
 }
 /**
  *
  * @param $config
  */
 public function __construct($config)
 {
     $server = $config['connection'][$config['default_connection']];
     $config = $config['configuration'][$config['default_connection']];
     $configuration = new Configuration();
     AnnotationDriver::registerAnnotationClasses();
     $anotationReader = new AnnotationDriver(new AnnotationReader(), app_path('Documents'));
     $configuration->setProxyDir($config['proxy_dir']);
     $configuration->setProxyNamespace('Proxies');
     $configuration->setHydratorDir($config['hydrator_dir']);
     $configuration->setHydratorNamespace('Hydrators');
     $configuration->setMetadataDriverImpl($anotationReader);
     $configuration->setDefaultDB($server['dbname']);
     $this->dm = DocumentManager::create(new Connection(), $configuration);
 }
 /**
  * @return DocumentManager
  */
 public function getDm()
 {
     $params = ['server' => 'localhost', 'database' => 'doctrine_tutorial', 'metadata_paths' => [__DIR__ . '/../src/Menu/mapping']];
     $cacheDir = __DIR__ . '/../cache';
     $config = new Configuration();
     $config->setProxyDir($cacheDir . '/Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir($cacheDir . '/Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB($params['database']);
     $config->setMetadataDriverImpl(new YamlDriver($params['metadata_paths']));
     $connection = new Connection($params['server'], array(), $config);
     // Create instance
     return DocumentManager::create($connection, $config);
 }
 public static function create(Connection $conn = null, Configuration $config = null, EventManager $eventManager = null)
 {
     if (is_null($config)) {
         $config = new \Doctrine\ODM\MongoDB\Configuration();
         $config->setProxyDir(__DIR__ . '/../Proxies');
         $config->setProxyNamespace('Doctrine\\Tests\\Proxies');
         $config->setHydratorDir(__DIR__ . '/../Hydrators');
         $config->setHydratorNamespace('Doctrine\\Tests\\Hydrators');
         $config->setMetadataDriverImpl(\Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::create());
     }
     if (is_null($eventManager)) {
         $eventManager = new \Doctrine\Common\EventManager();
     }
     return new DocumentManagerMock($conn, $config, $eventManager);
 }
 /**
  * @return EntityManager
  */
 public static function createTestDocumentManager($paths = array())
 {
     if (!class_exists('PDO') || !in_array('pgsql', \PDO::getAvailableDrivers())) {
         self::markTestSkipped('This test requires PgSQL support in your environment');
     }
     $config = new Configuration();
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setHydratorDir(\sys_get_temp_dir());
     $config->setProxyNamespace('GenemuFormBundleTests\\Doctrine');
     $config->setHydratorNamespace('GenemuFormBundleTests\\Doctrine');
     $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), $paths));
     $config->setMetadataCacheImpl(new ArrayCache());
     return DocumentManager::create(new Connection(), $config);
 }
 private function loadDoctrineMongoDBConfiguration(Application $app)
 {
     $app['doctrine.odm.mongodb.configuration'] = $app->share(function () use($app) {
         $config = new Configuration();
         $config->setMetadataCacheImpl($app['doctrine.odm.mongodb.metadata_cache']);
         if (isset($app['doctrine.odm.mongodb.connection_options']['database'])) {
             $config->setDefaultDB($app['doctrine.odm.mongodb.connection_options']['database']);
         }
         $chain = new MappingDriverChain();
         $usingAnnotations = false;
         foreach ((array) $app['doctrine.odm.mongodb.documents'] as $document) {
             switch ($document['type']) {
                 case 'annotation':
                     $driver = AnnotationDriver::create((array) $document['path']);
                     $chain->addDriver($driver, $document['namespace']);
                     $usingAnnotations = true;
                     break;
                 case 'yml':
                     $driver = new YamlDriver((array) $document['path'], '.yml');
                     $chain->addDriver($driver, $document['namespace']);
                     break;
                 case 'xml':
                     $driver = new XmlDriver((array) $document['path'], '.xml');
                     $chain->addDriver($driver, $document['namespace']);
                     break;
                 default:
                     throw new \InvalidArgumentException(sprintf('"%s" is not a recognized driver', $document['type']));
                     break;
             }
             // add namespace alias
             if (isset($document['alias'])) {
                 $config->addDocumentNamespace($document['alias'], $document['namespace']);
             }
         }
         if ($usingAnnotations) {
             AnnotationDriver::registerAnnotationClasses();
         }
         $config->setMetadataDriverImpl($chain);
         $config->setProxyDir($app['doctrine.odm.mongodb.proxies_dir']);
         $config->setProxyNamespace($app['doctrine.odm.mongodb.proxies_namespace']);
         $config->setAutoGenerateProxyClasses($app['doctrine.odm.mongodb.auto_generate_proxies']);
         $config->setHydratorDir($app['doctrine.odm.mongodb.hydrators_dir']);
         $config->setHydratorNamespace($app['doctrine.odm.mongodb.hydrators_namespace']);
         $config->setAutoGenerateHydratorClasses($app['doctrine.odm.mongodb.auto_generate_hydrators']);
         $config->setLoggerCallable($app['doctrine.odm.mongodb.logger_callable']);
         return $config;
     });
 }