/** * 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; }