Skip to content
Snippets Groups Projects
Commit a77354fd authored by Demian Katz's avatar Demian Katz
Browse files

Add useFrbrGroupingForHoldings WorldCat setting.

parent 3d5f3125
No related merge requests found
......@@ -69,3 +69,10 @@ related[] = "WorldCatSimilar"
; regular Syndetics if necessary.
[List]
view=full
; This section contains additional settings to pass to the WorldCat connector
; code.
[Connector]
; When looking up holdings at other libraries, should we retrieve holdings for
; any record matching the FRBR group (true) or only for exact matches (false)?
;useFrbrGroupingForHoldings = false
\ No newline at end of file
......@@ -69,6 +69,13 @@ class WorldCatBackendFactory implements FactoryInterface
*/
protected $config;
/**
* WorldCat configuration
*
* @var \Zend\Config\Config
*/
protected $wcConfig;
/**
* Create the backend.
*
......@@ -80,6 +87,8 @@ class WorldCatBackendFactory implements FactoryInterface
{
$this->serviceLocator = $serviceLocator;
$this->config = $this->serviceLocator->get('VuFind\Config')->get('config');
$this->wcConfig = $this->serviceLocator
->get('VuFind\Config')->get('WorldCat');
if ($this->serviceLocator->has('VuFind\Logger')) {
$this->logger = $this->serviceLocator->get('VuFind\Logger');
}
......@@ -112,8 +121,11 @@ class WorldCatBackendFactory implements FactoryInterface
{
$wsKey = isset($this->config->WorldCat->apiKey)
? $this->config->WorldCat->apiKey : null;
$connectorOptions = isset($this->wcConfig->Connector)
? $this->wcConfig->Connector->toArray() : [];
$connector = new Connector(
$wsKey, $this->serviceLocator->get('VuFind\Http')->createClient()
$wsKey, $this->serviceLocator->get('VuFind\Http')->createClient(),
$connectorOptions
);
$connector->setLogger($this->logger);
return $connector;
......
......@@ -47,18 +47,28 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector
*/
protected $wskey;
/**
* Additional options
*
* @var array
*/
protected $options;
/**
* Constructor
*
* @param string $wsKey Web services key
* @param \Zend\Http\Client $client An HTTP client object
* @param string $wsKey Web services key
* @param \Zend\Http\Client $client An HTTP client object
* @param array $options Additional config settings
*/
public function __construct($wsKey, \Zend\Http\Client $client)
{
public function __construct($wsKey, \Zend\Http\Client $client,
array $options = []
) {
parent::__construct(
'http://www.worldcat.org/webservices/catalog/search/sru', $client
);
$this->wskey = $wsKey;
$this->options = $options;
}
/**
......@@ -72,8 +82,13 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector
public function getHoldings($id)
{
$this->client->resetParameters();
$uri = "http://www.worldcat.org/webservices/catalog/content/libraries/{$id}";
$uri .= "?wskey={$this->wskey}&servicelevel=full";
if (!isset($this->options['useFrbrGroupingForHoldings'])) {
$grouping = 'on'; // default to "on" for backward compatibility
} else {
$grouping = $this->options['useFrbrGroupingForHoldings'] ? 'on' : 'off';
}
$uri = "http://www.worldcat.org/webservices/catalog/content/libraries/{$id}"
. "?wskey={$this->wskey}&servicelevel=full&frbrGrouping=$grouping";
$this->client->setUri($uri);
$this->debug('Connect: ' . $uri);
$result = $this->client->setMethod('POST')->send();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment