/** * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator * @return \Doctrine\ODM\Couch\DocumentManager */ public function createService(ServiceLocatorInterface $serviceLocator) { $options = $this->getOptions($serviceLocator, 'documentmanager'); $connection = $serviceLocator->get($options->getConnection()); $config = $serviceLocator->get($options->getConfiguration()); $eventManager = $serviceLocator->get($options->getEventManager()); return DocumentManager::create($connection, $config, $eventManager); }
public function setUp() { $this->type = 'Doctrine\\Tests\\ODM\\CouchDB\\UoWUser'; $this->dm = \Doctrine\ODM\CouchDB\DocumentManager::create(array('dbname' => 'test')); $this->uow = new UnitOfWork($this->dm); $metadata = new \Doctrine\ODM\CouchDB\Mapping\ClassMetadata($this->type); $metadata->mapField(array('fieldName' => 'id', 'id' => true)); $metadata->mapField(array('fieldName' => 'username', 'type' => 'string')); $metadata->idGenerator = \Doctrine\ODM\CouchDB\Mapping\ClassMetadata::IDGENERATOR_ASSIGNED; $cmf = $this->dm->getClassMetadataFactory(); $cmf->setMetadataFor($this->type, $metadata); }
public function createDocumentManager() { $couchDBClient = $this->createCouchDBClient(); $httpClient = $couchDBClient->getHttpClient(); $database = $couchDBClient->getDatabase(); $httpClient->request('DELETE', '/' . $database); $resp = $httpClient->request('PUT', '/' . $database); $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\Annotations'); $paths = __DIR__ . "/../../Models"; $metaDriver = new AnnotationDriver($reader, $paths); $config = $this->createConfiguration($metaDriver); return DocumentManager::create($couchDBClient, $config); }
static public function createOdm( $database, $host = 'localhost', $port = '5984', $username = null, $password = null, array $path = array(), $namespace = 'Doctrine\ODM\CouchDB\Mapping\\') { $driver = self::loadDriverForDocuments($path, $namespace); $config = new Configuration(); $config->setDatabase($database); $config->setMetadataDriverImpl($driver); $httpClient = new SocketClient($host, $port, $username, $password); $config->setHttpClient($httpClient); return DocumentManager::create($config); }
public function createDocumentManager() { $couchDBClient = $this->createCouchDBClient(); $httpClient = $couchDBClient->getHttpClient(); $database = $couchDBClient->getDatabase(); $httpClient->request('DELETE', '/' . $database); $resp = $httpClient->request('PUT', '/' . $database); $reader = new AnnotationReader(); $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\'); $paths = __DIR__ . "/../../Models"; $metaDriver = new AnnotationDriver($reader, $paths); $config = new Configuration(); $config->setProxyDir(\sys_get_temp_dir()); $config->setMetadataDriverImpl($metaDriver); $setMetadataCacheImpl = $config->setMetadataCacheImpl(new ArrayCache()); $config->setLuceneHandlerName('_fti'); return DocumentManager::create($couchDBClient, $config); }
public function testCreateNewDocumentManagerWithoutHttpClientUsingSocketDefault() { $dm = \Doctrine\ODM\CouchDB\DocumentManager::create(array('dbname' => 'test')); $this->assertInstanceOf('Doctrine\\CouchDB\\HTTP\\SocketClient', $dm->getHttpClient()); }
/** * Constructs and sets all options at once. * * @param array $options * * Options are: * * @option string $dbname The name of the database * @option string $type The connection type, "socket" or "stream" * @option string $host * @option int $port * @option string $user * @option string $password * @option string $ip * @option bool $logging * @option Configuration $config * @option EventManager $manager * @option array $namespaces Array of additional document namespaces * * @return \Doctrine\ODM\CouchDB\DocumentManager */ public static function documentManager($options = array()) { $_key = Option::get($options, 'host', 'localhost') . ':' . Option::get($options, 'port', 5984); if (!isset(self::$_dms[$_key])) { self::$_dms[$_key] = \Doctrine\ODM\CouchDB\DocumentManager::create(Option::get($options, 'client', static::couchDbClient($options)), Option::get($options, 'config'), Option::get($options, 'manager')); } return self::$_dms[$_key]; }
/** * Creates a Doctrine ODM DocumentManager * * @return \Doctrine\ODM\CouchDB\DocumentManager */ public function create() { if (isset($this->documentManager)) { return $this->documentManager; } $httpClient = new \Doctrine\CouchDB\HTTP\SocketClient($this->settings['host'], $this->settings['port'], $this->settings['username'], $this->settings['password'], $this->settings['ip']); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $metaDriver = new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader); $config = new \Doctrine\ODM\CouchDB\Configuration(); $config->setMetadataDriverImpl($metaDriver); $packages = $this->packageManager->getActivePackages(); foreach ($packages as $package) { $designDocumentRootPath = \TYPO3\Flow\Utility\Files::concatenatePaths(array($package->getPackagePath(), 'Migrations/CouchDB/DesignDocuments')); if (is_dir($designDocumentRootPath)) { $packageDesignDocumentFolders = glob($designDocumentRootPath . '/*'); foreach ($packageDesignDocumentFolders as $packageDesignDocumentFolder) { if (is_dir($packageDesignDocumentFolder)) { $designDocumentName = strtolower(basename($packageDesignDocumentFolder)); $config->addDesignDocument($designDocumentName, 'Radmiraal\\CouchDB\\View\\Migration', array('packageKey' => $package->getPackageKey(), 'path' => $packageDesignDocumentFolder)); } } } } $proxyDirectory = \TYPO3\Flow\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'DoctrineODM/Proxies')); \TYPO3\Flow\Utility\Files::createDirectoryRecursively($proxyDirectory); $config->setProxyDir($proxyDirectory); $config->setProxyNamespace('TYPO3\\Flow\\Persistence\\DoctrineODM\\Proxies'); $config->setAutoGenerateProxyClasses(TRUE); $couchClient = new \Doctrine\CouchDB\CouchDBClient($httpClient, $this->settings['databaseName']); $this->documentManager = \Doctrine\ODM\CouchDB\DocumentManager::create($couchClient, $config); return $this->documentManager; }
public function setUp() { $this->dm = \Doctrine\ODM\CouchDB\DocumentManager::create(array('dbname' => 'test')); }
public function getMetadataFactory() { $dm = \Doctrine\ODM\CouchDB\DocumentManager::create(array('dbname' => 'test')); return new \Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory($dm); }