/** * Retrieve a single document. * * @param string $id Document identifier * @param ParamBag $params Search backend parameters * * @return RecordCollectionInterface */ public function retrieve($id, ParamBag $params = null) { try { $response = $this->connector->getRecord($id, $this->connector->getInstitutionCode()); } catch (\Exception $e) { // TODO: check from database, this could be in a favorite list throw new BackendException($e->getMessage(), $e->getCode(), $e); } $response['id'] = $id; $collection = $this->createRecordCollection(['documents' => [$response]]); return $collection; }
/** * Create the MetaLib connector. * * @return Connector */ protected function createConnector() { $institution = $this->config->General->institution ?: null; $host = $this->config->General->url ?: null; $user = $this->config->General->x_user ?: null; $pass = $this->config->General->x_password ?: null; $client = $this->serviceLocator->get('VuFind\\Http')->createClient(); $table = $this->serviceLocator->get('VuFind\\DbTablePluginManager')->get('metalibSearch'); $auth = $this->serviceLocator->get('ZfcRbac\\Service\\AuthorizationService'); $configReader = $this->serviceLocator->get('VuFind\\Config'); $sets = $configReader->get('MetaLibSets')->toArray(); $timeout = isset($this->config->General->timeout) ? $this->config->General->timeout : 60; $client->setOptions(['timeout' => $timeout]); /** * Should boolean operators in the search string be treated as * case-insensitive (false), or must they be ALL UPPERCASE (true)? */ $luceneHelper = isset($this->config->General->case_sensitive_bools) && !$this->config->General->case_sensitive_bools ? new LuceneSyntaxHelper() : null; $connector = new Connector($institution, $host, $user, $pass, $client, $table, $auth, $sets, $luceneHelper); $connector->setLogger($this->logger); return $connector; }