Skip to content
Merged
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
18 changes: 8 additions & 10 deletions module/VuFind/src/VuFind/Recommend/AbstractFacets.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

namespace VuFind\Recommend;

use VuFind\Config\Config;

use function in_array;

/**
Expand Down Expand Up @@ -127,29 +125,29 @@ public function getResults()
/**
* Read boolean (OR/NOT) settings from the provided configuration.
*
* @param Config $config Configuration to read
* @param array $config Configuration to read
Comment thread
rtloftus marked this conversation as resolved.
* @param array $allFacets All facets (to use when config = *)
* @param string $section Configuration section containing settings
*
* @return void
*/
protected function loadBooleanConfigs(
Config $config,
$config,
Comment thread
rtloftus marked this conversation as resolved.
Outdated
$allFacets,
$section = 'Results_Settings'
) {
// Which facets are excludable?
if (isset($config->$section->exclude)) {
$this->excludableFacets = ($config->$section->exclude === '*')
if (isset($config['$section']['exclude'])) {
$this->excludableFacets = ($config['$section']['exclude'] === '*')
? $allFacets
: array_map('trim', explode(',', $config->$section->exclude));
: array_map('trim', explode(',', $config['$section']['exclude']));
}

// Which facets are ORed?
if (isset($config->$section->orFacets)) {
$this->orFacets = ($config->$section->orFacets === '*')
if (isset($config['$section']['orFacets'])) {
$this->orFacets = ($config['$section']['orFacets'] === '*')
? $allFacets
: array_map('trim', explode(',', $config->$section->orFacets));
: array_map('trim', explode(',', $config['$section']['orFacets']));
}
}
}
25 changes: 8 additions & 17 deletions module/VuFind/src/VuFind/Recommend/ConsortialVuFind.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

namespace VuFind\Recommend;

use VuFind\Config\Config;
use VuFind\Connection\ExternalVuFind as Connection;

use function intval;
Expand Down Expand Up @@ -74,13 +73,6 @@ class ConsortialVuFind implements RecommendInterface, \Psr\Log\LoggerAwareInterf
*/
protected $connection;

/**
* ConsortialVuFind.ini configuration.
*
* @var Config
*/
protected $config;

/**
* Base URL of a search results page.
*
Expand Down Expand Up @@ -119,14 +111,13 @@ class ConsortialVuFind implements RecommendInterface, \Psr\Log\LoggerAwareInterf
/**
* Constructor.
*
* @param Config $config ConsortialVuFind.ini configuration
* @param array $config ConsortialVuFind.ini configuration
* @param Connection $connection Connection to consortial VuFind API
*/
public function __construct(
Config $config,
protected array $config,
Comment thread
rtloftus marked this conversation as resolved.
Outdated
Connection $connection
) {
$this->config = $config;
$this->connection = $connection;
}

Expand All @@ -146,19 +137,19 @@ public function setConfig($settings)
$configSectionName = $settings[2] ?? 'ReShare';

// Read config file
$configSection = $this->config->get($configSectionName);
$configSection = $this->config['$configSectionName'];
Comment thread
rtloftus marked this conversation as resolved.
Outdated
if ($configSection) {
$this->resultsBaseUrl = $configSection->results_base_url;
$this->recordBaseUrl = $configSection->record_base_url;
$this->searchFilters = $configSection->filters?->toArray() ?? [];
$this->resultsBaseUrl = $configSection['results_base_url'];
$this->recordBaseUrl = $configSection['record_base_url'];
$this->searchFilters = $configSection['filters'] ?? [];

// Configure connection
$this->connection->setBaseUrl($configSection->api_base_url);
$this->connection->setBaseUrl($configSection['api_base_url']);

// Confirm that required configuration is present
$this->hasMinimumConfig = $this->resultsBaseUrl
&& $this->recordBaseUrl
&& $configSection->api_base_url;
&& $configSection['api_base_url'];
if (!$this->hasMinimumConfig) {
$this->logError("Required configuration missing in '$configSectionName'
section of ConsortialVuFind.ini.");
Expand Down
10 changes: 4 additions & 6 deletions module/VuFind/src/VuFind/Recommend/LibGuidesProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
namespace VuFind\Recommend;

use Laminas\Cache\Storage\StorageInterface as CacheAdapter;
use VuFind\Config\Config;
use VuFind\Connection\LibGuides;

use function intval;
use function is_string;
use function strlen;

Expand Down Expand Up @@ -105,21 +103,21 @@ class LibGuidesProfile implements
* Constructor.
*
* @param LibGuides $libGuides LibGuides API connection
* @param Config $config LibGuides API configuration object
* @param array $config LibGuides API configuration object
* @param CacheAdapter $cache Object cache
*/
public function __construct(
LibGuides $libGuides,
Config $config,
array $config,
Comment thread
rtloftus marked this conversation as resolved.
Outdated
CacheAdapter $cache
) {
$this->libGuides = $libGuides;
$this->setCacheStorage($cache);

// Cache the data related to profiles for up to 10 minutes:
$this->cacheLifetime = intval($config->GetAccounts->cache_lifetime ?? 600);
$this->cacheLifetime = (int)($config['GetAccounts']['cache_lifetime'] ?? 600);

if ($profile = $config->Profile->toArray()) {
if ($profile = $config['Profile']) {
$strategies = $profile['strategies'] ?? [];
$this->strategies = is_string($strategies) ? [$strategies] : $strategies;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

namespace VuFindTest\Recommend;

use VuFind\Config\Config;
use VuFind\Config\ConfigManagerInterface;
use VuFind\Connection\ExternalVuFind;
use VuFind\Recommend\ConsortialVuFind;
Expand Down Expand Up @@ -144,7 +143,7 @@ protected function buildConfig(): array
*/
protected function buildConsortialVuFind(array $config): ConsortialVuFind
{
$consortialVuFind = new ConsortialVuFind(new Config($config), $this->connector);
$consortialVuFind = new ConsortialVuFind($config, $this->connector);
$consortialVuFind->setConfig('lookfor:3:ReShare');

$queryResults = $this->buildQueryResults('civil war');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

use Laminas\Cache\Storage\StorageInterface as CacheAdapter;
use PHPUnit\Framework\MockObject\MockObject;
use VuFind\Config\Config;
use VuFind\Config\ConfigManagerInterface;
use VuFind\Connection\LibGuides;
use VuFind\Recommend\LibGuidesProfile;
Expand Down Expand Up @@ -201,7 +200,7 @@ protected function buildProfile(array $config): LibGuidesProfile&MockObject

// For the target class LibGuidesProfile, only mock the caching methods
$libGuidesProfile = $this->getMockBuilder(LibGuidesProfile::class)
->setConstructorArgs([$this->connector, new Config($config), $this->cacheAdapter])
->setConstructorArgs([$this->connector, $config, $this->cacheAdapter])
->onlyMethods(['getCachedData', 'putCachedData'])
->getMock();
$libGuidesProfile->method('getCachedData')->willReturn(null);
Expand Down
Loading