fix: remove dependency Bsr\Configuration

This commit is contained in:
Guillermo Pages
2021-07-27 19:28:11 +02:00
parent 8245027a74
commit 78cab08ac0
3 changed files with 10 additions and 1562 deletions

View File

@@ -11,18 +11,5 @@
],
"autoload": {
"psr-4": {"Bsr\\" : "src/"}
},
"repositories" : [
{
"type" : "vcs",
"url" : "https://usrpath@bitbucket.org/usrpath/bsrutils.git"
}
],
"require" : {
"bsr/utils" : "dev-master"
},
"require-dev": {
"pds/skeleton": "^1.0",
"phpunit/phpunit": "^6"
}
}

1534
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -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'];
}