fix: remove dependency Bsr\Configuration
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Bsr\BookSearch;
|
||||
|
||||
use Bsr\Utils\Configuration\Configuration;
|
||||
use Bsr\BookSearch\Exception\WebException;
|
||||
//use Bsr\Webservice\Logger;
|
||||
|
||||
mb_http_output('UTF-8');
|
||||
|
||||
@@ -19,16 +17,9 @@ class BookSearch
|
||||
/** @var array parts of the filter query, parameter 'fq' */
|
||||
private $filterQueryParts = array();
|
||||
|
||||
public function __construct($edismax = true)
|
||||
public function __construct(string $hostname, int $port, string $login, string $password, string $path, $edismax = true)
|
||||
{
|
||||
$options = array
|
||||
(
|
||||
'hostname' => Configuration::get('solr.server'),
|
||||
'port' => Configuration::get('solr.port'),
|
||||
'login' => Configuration::get('solr.username'),
|
||||
'password' => Configuration::get('solr.password'),
|
||||
'path' => Configuration::get('solr.path'),
|
||||
);
|
||||
$options = compact('hostname', 'port', 'login', 'password', 'path');
|
||||
|
||||
$this->client = new \SolrClient($options);
|
||||
|
||||
@@ -42,14 +33,6 @@ class BookSearch
|
||||
// most options like search fields, sorting, etc are already set
|
||||
// as default in the Solr config and thus should be set only on a
|
||||
// per request basis when needed
|
||||
|
||||
/* if sometime we need to set the fields explicitly, those should be the ones we want :
|
||||
$this->query->addField('id, code, isbn');
|
||||
$this->query->addField('editor, editorTown, year, producer, producerCode, availabilityDate, collection');
|
||||
$this->query->addField('title, author, reader, summary');
|
||||
$this->query->addField('jeunesse, genre, genreCode, motsMatieres, cdu');
|
||||
$this->query->addField('media, mediaType, cover, samples, zip, zip_size');
|
||||
*/
|
||||
}
|
||||
|
||||
public function setHandler($handler)
|
||||
@@ -166,7 +149,7 @@ class BookSearch
|
||||
$this->query->setParam('hl', $highlight ? 'true' : 'false');
|
||||
$this->query->setParam('spellcheck', $spellcheck ? 'true' : 'false');
|
||||
|
||||
|
||||
|
||||
try {
|
||||
$results = $this->client->query($this->query)->getArrayResponse();
|
||||
} catch(\SolrException $e) {
|
||||
@@ -297,7 +280,7 @@ class BookSearch
|
||||
|
||||
$bs = new static();
|
||||
$bs->addOrQuery($codes, $field);
|
||||
|
||||
|
||||
$results = $bs->getResults(0, $count);
|
||||
return $results['books'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user