Databases
in package
implements
RecommendInterface, LoggerAwareInterface
Uses
CacheTrait, LoggerAwareTrait
Databases Recommendations Module
This class displays a list of external links to the research databases represented by EDS or similar results. (Unlike the EDS ContentProvider facet that would narrow down the results within VuFind.)
Tags
Interfaces, Classes, Traits and Enums
- RecommendInterface
- Search Recommendations Interface
- LoggerAwareInterface
Table of Contents
- $cache : StorageInterface
- Cache for storing data temporarily (e.g. patron blocks with the ILS driver)
- $cacheLifetime : int
- Lifetime of cache (in seconds).
- $configFileDatabases : array<string|int, mixed>
- Databases listed in configuration file
- $configManager : ConfigManager
- Configuration manager
- $libGuidesGetter : callable
- Callable for LibGuides connector
- $limit : int
- Number of results to show
- $linkToAllDatabases : mixed
- URL to a list of all available databases, for display in the results list, or false to omit.
- $resultFacet : array<string|int, mixed>
- The result facet with the list of databases. Each value in the array is a level of the facet hierarchy.
- $resultFacetNameKey : string
- For each database facet, the key to the database name.
- $results : Results
- Results object
- $useLibGuides : bool
- Configuration of whether to use LibGuides as a data source
- $useLibGuidesAlternateNames : bool
- Configuration of whether to match on the alt_names field in LibGuides in addition to the primary name
- $useQuery : bool
- Configuration of whether to use the query string as a match point
- $useQueryMinLength : bool
- Minimum string length of a query to use as a match point
- __construct() : mixed
- Constructor
- getLinkToAllDatabases() : string
- Get a URL to a list of all available databases, if configured.
- getResults() : array<string|int, mixed>
- Get terms related to the query.
- init() : void
- Called before the Search Results object performs its main search (specifically, in response to \VuFind\Search\SearchRunner::EVENT_CONFIGURED).
- process() : void
- Called after the Search Results object has performed its main search. This may be used to extract necessary information from the Search Results object or to perform completely unrelated processing.
- setCacheStorage() : void
- Set a cache storage object.
- setConfig() : void
- Store the configuration of the recommendation module.
- debug() : void
- Log a debug message.
- getCachedData() : mixed|null
- Helper function for fetching cached data.
- getDatabases() : An
- Generate a combined list of databases from all enabled sources.
- getLibGuidesDatabases() : array<string|int, mixed>
- Load or retrieve from the cache the list of LibGuides A-Z databases.
- log() : void
- Send a message to the logger.
- logError() : void
- Log an error message.
- logWarning() : void
- Log a warning message.
- putCachedData() : void
- Helper function for storing cached data.
- removeCachedData() : void
- Helper function for removing cached data.
Properties
$cache
Cache for storing data temporarily (e.g. patron blocks with the ILS driver)
protected
StorageInterface
$cache
= null
$cacheLifetime
Lifetime of cache (in seconds).
protected
int
$cacheLifetime
= 30
$configFileDatabases
Databases listed in configuration file
protected
array<string|int, mixed>
$configFileDatabases
= []
$configManager
Configuration manager
protected
ConfigManager
$configManager
$libGuidesGetter
Callable for LibGuides connector
protected
callable
$libGuidesGetter
$limit
Number of results to show
protected
int
$limit
= 5
$linkToAllDatabases
URL to a list of all available databases, for display in the results list, or false to omit.
protected
mixed
$linkToAllDatabases
= false
$resultFacet
The result facet with the list of databases. Each value in the array is a level of the facet hierarchy.
protected
array<string|int, mixed>
$resultFacet
= []
$resultFacetNameKey
For each database facet, the key to the database name.
protected
string
$resultFacetNameKey
= 'value'
$results
Results object
protected
Results
$results
$useLibGuides
Configuration of whether to use LibGuides as a data source
protected
bool
$useLibGuides
= false
$useLibGuidesAlternateNames
Configuration of whether to match on the alt_names field in LibGuides in addition to the primary name
protected
bool
$useLibGuidesAlternateNames
= true
$useQuery
Configuration of whether to use the query string as a match point
protected
bool
$useQuery
= true
$useQueryMinLength
Minimum string length of a query to use as a match point
protected
bool
$useQueryMinLength
= 3
Methods
__construct()
Constructor
public
__construct(PluginManager $configManager, callable $libGuidesGetter, StorageInterface $cache) : mixed
Parameters
- $configManager : PluginManager
-
Config PluginManager
- $libGuidesGetter : callable
-
Getter for LibGuides API connection
- $cache : StorageInterface
-
Object cache
Return values
mixed —getLinkToAllDatabases()
Get a URL to a list of all available databases, if configured.
public
getLinkToAllDatabases() : string
Return values
string —The URL, or null.
getResults()
Get terms related to the query.
public
getResults() : array<string|int, mixed>
Return values
array<string|int, mixed> —init()
Called before the Search Results object performs its main search (specifically, in response to \VuFind\Search\SearchRunner::EVENT_CONFIGURED).
public
init(Params $params, Parameters $request) : void
This method is responsible for setting search parameters needed by the recommendation module and for reading any existing search parameters that may be needed.
Parameters
- $params : Params
-
Search parameter object
- $request : Parameters
-
Parameter object representing user request.
Tags
Return values
void —process()
Called after the Search Results object has performed its main search. This may be used to extract necessary information from the Search Results object or to perform completely unrelated processing.
public
process(Results $results) : void
Parameters
- $results : Results
-
Search results object
Return values
void —setCacheStorage()
Set a cache storage object.
public
setCacheStorage([StorageInterface $cache = null ]) : void
Parameters
- $cache : StorageInterface = null
-
Cache storage interface
Return values
void —setConfig()
Store the configuration of the recommendation module.
public
setConfig(string $settings) : void
Parameters
- $settings : string
-
Settings from searches.ini.
Return values
void —debug()
Log a debug message.
protected
debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —getCachedData()
Helper function for fetching cached data.
protected
getCachedData(string $key) : mixed|null
Data is cached for up to $this->cacheLifetime.
Parameters
- $key : string
-
Cache entry key
Return values
mixed|null —Cached entry or null if not cached or expired
getDatabases()
Generate a combined list of databases from all enabled sources.
protected
getDatabases() : An
Return values
An —array mapping a database name to a sub-array with the url.
getLibGuidesDatabases()
Load or retrieve from the cache the list of LibGuides A-Z databases.
protected
getLibGuidesDatabases() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array mapping a database name to an array representing the full object retrieved from the LibGuides /az API.
log()
Send a message to the logger.
protected
log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
- $level : string
-
Log level
- $message : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = false
-
Prepend class name to message?
Return values
void —logError()
Log an error message.
protected
logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —logWarning()
Log a warning message.
protected
logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —putCachedData()
Helper function for storing cached data.
protected
putCachedData(string $key, mixed $entry[, int $lifetime = null ]) : void
Data is cached for up to $this->cacheLifetime seconds.
Parameters
- $key : string
-
Cache entry key
- $entry : mixed
-
Entry to be cached
- $lifetime : int = null
-
Optional lifetime for the entry in seconds
Return values
void —removeCachedData()
Helper function for removing cached data.
protected
removeCachedData(string $key) : void
Parameters
- $key : string
-
Cache entry key