Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 10 additions & 26 deletions module/VuFind/src/VuFind/Connection/Relais.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,14 @@ class Relais implements \Psr\Log\LoggerAwareInterface
{
use \VuFind\Log\LoggerAwareTrait;

/**
* HTTP client.
*
* @var Client
*/
protected $client;

/**
* Relais configuration.
*
* @var Config
*/
protected $config;

/**
* Constructor.
*
* @param Client $client HTTP client
* @param Config $config Relais configuration
* @param array $config Relais configuration
*/
public function __construct(Client $client, Config $config)
public function __construct(protected Client $client, protected array $config)
Comment thread
rtloftus marked this conversation as resolved.
{
$this->client = $client;
$this->config = $config;
}

/**
Expand All @@ -79,10 +63,10 @@ public function __construct(Client $client, Config $config)
protected function getDefaultData()
{
return [
'ApiKey' => $this->config->apikey ?? null,
'ApiKey' => $this->config['apikey'] ?? null,
'UserGroup' => 'PATRON',
'PartnershipId' => $this->config->group ?? null,
'LibrarySymbol' => $this->config->symbol ?? null,
'PartnershipId' => $this->config['group'] ?? null,
'LibrarySymbol' => $this->config['symbol'] ?? null,
];
}

Expand All @@ -97,9 +81,9 @@ protected function getDefaultData()
protected function getOclcRequestData($oclc, $patron)
{
return [
'PickupLocation' => $this->config->pickupLocation ?? null,
'PickupLocation' => $this->config['pickupLocation'] ?? null,
'Notes' => 'This request was made through the VuFind Catalog interface',
'PatronId' => $patron ?? $this->config->patronForLookup ?? null,
'PatronId' => $patron ?? $this->config['patronForLookup'] ?? null,
'ExactSearch' => [
[
'Type' => 'OCLC',
Expand Down Expand Up @@ -145,11 +129,11 @@ protected function request($uri, $data)
*/
public function authenticatePatron($patron = null, $returnFullObject = false)
{
$uri = $this->config->authenticateurl ?? null;
$uri = $this->config['authenticateurl'] ?? null;
if (empty($uri)) {
throw new \Exception('authenticateurl not configured!');
}
$data = ['PatronId' => $patron ?? $this->config->patronForLookup ?? null];
$data = ['PatronId' => $patron ?? $this->config['patronForLookup'] ?? null];
$result = json_decode($this->request($uri, $data));
return $returnFullObject ? $result : ($result->AuthorizationId ?? null);
}
Expand All @@ -166,7 +150,7 @@ public function authenticatePatron($patron = null, $returnFullObject = false)
*/
public function placeRequest($oclc, $auth, $patron = null)
{
$uri = $this->config->addurl ?? null;
$uri = $this->config['addurl'] ?? null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at line 173 below -- I think there's one last object-style reference that still needs to be converted.

if (empty($uri)) {
throw new \Exception('addurl not configured!');
}
Expand Down
8 changes: 4 additions & 4 deletions module/VuFind/src/VuFind/Connection/RelaisFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public function __invoke(
if (!empty($options)) {
throw new \Exception('Unexpected options passed to factory.');
}
$config = $container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigObject('config');
$url = $config->Relais->authenticateurl ?? null;
$config = $container->get(\VuFind\Config\ConfigManagerInterface::class)->getConfigArray('config');
$url = $config['Relais']['authenticateurl'] ?? null;
$client = $container->get(\VuFindHttp\HttpService::class)
->createClient($url);
$client->setOptions(['timeout' => $config->Relais->timeout ?? 500]);
return new $requestedName($client, $config->Relais ?? null);
$client->setOptions(['timeout' => $config['Relais']['timeout'] ?? 500]);
return new $requestedName($client, $config['Relais'] ?? null);
Comment thread
rtloftus marked this conversation as resolved.
Outdated
}
}