LibGuidesProfile
in package
implements
RecommendInterface
Uses
CacheTrait, HttpServiceAwareTrait
LibGuides Profile Recommendations Module
Tags
Interfaces, Classes, Traits and Enums
- RecommendInterface
- Search Recommendations Interface
Table of Contents
- $aliasToAccountId : array<string|int, mixed>
- Map of config alias to LibGuides account ID
- $cache : StorageInterface
- Cache for storing data temporarily (e.g. patron blocks with the ILS driver)
- $cacheLifetime : int
- Lifetime of cache (in seconds).
- $callNumberField : string
- Facet field name containing the call numbers to match against
- $callNumberLength : int
- Length of the substring at the start of a call number to match against
- $callNumberToAlias : array<string|int, mixed>
- Map of call number pattern to config alias
- $libGuides : LibGuides
- LibGuides connector
- $results : Results
- Search results object
- $strategies : int
- List of strategies enabled to find a matching LibGuides profile
- __construct() : mixed
- Constructor
- 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.
- findBestMatchByCallNumber() : array<string|int, mixed>
- Find the LibGuides account whose profile best matches the call number facets in the given search results.
- findBestMatchBySubject() : array<string|int, mixed>
- Find the LibGuides account whose subject expertise in their profile best matches the given query.
- getCachedData() : mixed|null
- Helper function for fetching cached data.
- getLibGuidesData() : array<string|int, mixed>
- Load or retrieve from the cache the list of LibGuides accounts from the LibGuides API.
- populateLibGuidesCache() : array<string|int, mixed>
- Load the list of LibGuides accounts from the LibGuides API.
- putCachedData() : void
- Helper function for storing cached data.
- removeCachedData() : void
- Helper function for removing cached data.
Properties
$aliasToAccountId
Map of config alias to LibGuides account ID
protected
array<string|int, mixed>
$aliasToAccountId
$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
$callNumberField
Facet field name containing the call numbers to match against
protected
string
$callNumberField
$callNumberLength
Length of the substring at the start of a call number to match against
protected
int
$callNumberLength
$callNumberToAlias
Map of call number pattern to config alias
protected
array<string|int, mixed>
$callNumberToAlias
$libGuides
LibGuides connector
protected
LibGuides
$libGuides
$results
Search results object
protected
Results
$results
$strategies
List of strategies enabled to find a matching LibGuides profile
protected
int
$strategies
= []
Methods
__construct()
Constructor
public
__construct(LibGuides $libGuides, Config $config, StorageInterface $cache) : mixed
Parameters
- $libGuides : LibGuides
-
LibGuides API connection
- $config : Config
-
LibGuides API configuration object
- $cache : StorageInterface
-
Object cache
Return values
mixed —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 —findBestMatchByCallNumber()
Find the LibGuides account whose profile best matches the call number facets in the given search results.
protected
findBestMatchByCallNumber(Results $results) : array<string|int, mixed>
Adapted from Demian Katz: https://gist.github.com/demiankatz/4600bdfb9af9882ad491f74c406a8a8a#file-guide-php-L308
Parameters
- $results : Results
-
Search results object
Return values
array<string|int, mixed> —LibGuides account
findBestMatchBySubject()
Find the LibGuides account whose subject expertise in their profile best matches the given query.
protected
findBestMatchBySubject(Results $results) : array<string|int, mixed>
Parameters
- $results : Results
-
Search results object
Return values
array<string|int, mixed> —LibGuides account
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
getLibGuidesData()
Load or retrieve from the cache the list of LibGuides accounts from the LibGuides API.
protected
getLibGuidesData() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array containing the idToAccount and subjectToId maps
populateLibGuidesCache()
Load the list of LibGuides accounts from the LibGuides API.
protected
populateLibGuidesCache() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array containing the idToAccount and subjectToId maps
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