/** * Create the SOLR connector. * * @return Connector */ protected function createConnector() { $config = $this->config->get('config'); $handlers = ['select' => ['fallback' => true, 'defaults' => ['fl' => '*,score'], 'appends' => ['fq' => []]], 'term' => ['functions' => ['terms']]]; foreach ($this->getHiddenFilters() as $filter) { array_push($handlers['select']['appends']['fq'], $filter); } $connector = new Connector($this->getSolrUrl(), new HandlerMap($handlers), $this->uniqueKey); $connector->setTimeout(isset($config->Index->timeout) ? $config->Index->timeout : 30); if ($this->logger) { $connector->setLogger($this->logger); } if ($this->serviceLocator->has('VuFind\\Http')) { $connector->setProxy($this->serviceLocator->get('VuFind\\Http')); } return $connector; }
/** * Create connector with fixture file. * * @param string $fixture Fixture file * * @return Connector * * @throws InvalidArgumentException Fixture file does not exist */ protected function createConnector($fixture = null) { if ($fixture) { $file = realpath(sprintf('%s/solr/response/%s', PHPUNIT_SEARCH_FIXTURES, $fixture)); if (!is_string($file) || !file_exists($file) || !is_readable($file)) { throw new InvalidArgumentException(sprintf('Unable to load fixture file: %s', $file)); } $this->response = file_get_contents($file); } $map = new HandlerMap(['select' => ['fallback' => true]]); $conn = new Connector('http://example.tld/', $map); $conn->setProxy($this); return $conn; }