Since: 1.0
Author: Benjamin Eberlei (kontakt@beberlei.de)
Author: Lukas Kahwe Smith (smith@pooteeweet.org)
	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);
	}
Example #2
0
 /**
  * Create a CouchDB-Lucene Query.
  *
  * @param string $designDocName
  * @param string $viewName
  * @return View\ODMLuceneQuery
  */
 public function createLuceneQuery($designDocName, $viewName)
 {
     $luceneHandlerName = $this->config->getLuceneHandlerName();
     $designDoc = $this->config->getDesignDocument($designDocName);
     if ($designDoc) {
         $designDoc = new $designDoc['className']($designDoc['options']);
     }
     $query = new ODMLuceneQuery($this->couchDBClient->getHttpClient(), $this->couchDBClient->getDatabase(), $luceneHandlerName, $designDocName, $viewName, $designDoc);
     $query->setDocumentManager($this);
     return $query;
 }
 public function createConfiguration($metaDriver)
 {
     $config = new Configuration();
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setAutoGenerateProxyClasses(true);
     $config->setMetadataDriverImpl($metaDriver);
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setLuceneHandlerName('_fti');
     return $config;
 }
 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 = new Configuration();
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setAutoGenerateProxyClasses(true);
     $config->setMetadataDriverImpl($metaDriver);
     $setMetadataCacheImpl = $config->setMetadataCacheImpl(new ArrayCache());
     $config->setLuceneHandlerName('_fti');
     return DocumentManager::create($couchDBClient, $config);
 }