VuFind API Documentation

Connection
in package
implements TranslatorAwareInterface, LoggerAwareInterface Uses TranslatorAwareTrait, LoggerAwareTrait

Catalog Connection Class

This wrapper works with a driver class to pass information from the ILS to VuFind.

Tags
category

VuFind

author

Andrew S. Nagy vufind-tech@lists.sourceforge.net

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Interfaces, Classes, Traits and Enums

TranslatorAwareInterface
Lightweight translator aware marker interface (used as an alternative to \Laminas\I18n\Translator\TranslatorAwareInterface, which requires an excessive number of methods to be implemented).
LoggerAwareInterface

Table of Contents

$config  : Config
ILS configuration
$configReader  : PluginManager
Configuration loader
$driver  : object
The object of the appropriate driver.
$driverInitialized  : bool
Has the driver been initialized yet?
$driverManager  : PluginManager
Driver plugin manager
$failing  : bool
Is the current ILS driver failing?
$holdsMode  : string
Holds mode
$request  : Request
Request object
$titleHoldsMode  : string
Title-level holds mode
$translator  : TranslatorInterface
Translator
__call()  : mixed
Default method -- pass along calls to the driver if available; return false otherwise. This allows custom functions to be implemented in the driver without constant modification to the connection class.
__construct()  : mixed
Constructor
checkCapability()  : bool
Check driver capability -- return true if the driver supports the specified method; false otherwise.
checkFunction()  : mixed
Check Function
checkILLRequestIsValid()  : mixed
Check ILL Request is Valid
checkRequestIsValid()  : mixed
Check Request is Valid
checkStorageRetrievalRequestIsValid()  : mixed
Check Storage Retrieval Request is Valid
getDriver()  : object
Get access to the driver object.
getDriverClass()  : string
Get class name of the driver object.
getDriverConfig()  : array<string|int, mixed>
Get configuration for the ILS driver. We will load an .ini file named after the driver class if it exists; otherwise we will return an empty array.
getHolding()  : array<string|int, mixed>
Get holdings
getHoldingsTextFieldNames()  : array<string|int, string>
Get Names of Textual Holdings Fields
getHoldsMode()  : string
Get Holds Mode
getMyTransactions()  : mixed
Get Patron Transactions
getOfflineMode()  : string|bool
Get Offline Mode
getPasswordPolicy()  : bool|array<string|int, mixed>
Get the password policy from the driver
getStatus()  : array<string|int, mixed>
Get status
getStatuses()  : array<string|int, mixed>
Get statuses
getStatusParser()  : callable
Get a function that parses availability and status to an AvailabilityStatus object if necessary.
getTitleHoldsMode()  : string
Get Title Holds Mode
getTranslator()  : TranslatorInterface
Get translator object.
getTranslatorLocale()  : string
Get the locale from the translator.
hasHoldings()  : bool
Has Holdings
loginIsHidden()  : bool
Get Hidden Login Mode
setDriver()  : void
Set a driver object.
setHoldConfig()  : Connection
Set the hold configuration for the connection.
setTranslator()  : TranslatorAwareInterface
Set a translator
translate()  : string
Translate a string (or string-castable object)
translateWithPrefix()  : string
Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.
checkMethodcancelHolds()  : mixed
Check Cancel Holds
checkMethodcancelILLRequests()  : mixed
Check Cancel ILL Requests
checkMethodcancelStorageRetrievalRequests()  : mixed
Check Cancel Storage Retrieval Requests
checkMethodchangePassword()  : mixed
Check Password Change
checkMethodgetMyTransactionHistory()  : mixed
Check Historic Loans
checkMethodgetMyTransactions()  : mixed
Check Current Loans
checkMethodHolds()  : mixed
Check Holds
checkMethodILLRequests()  : mixed
Check ILL Request
checkMethodpatronLogin()  : mixed
Check Patron login
checkMethodpurgeTransactionHistory()  : mixed
Check Purge Historic Loans
checkMethodRenewals()  : mixed
Check Renewals
checkMethodStorageRetrievalRequests()  : mixed
Check Storage Retrieval Request
debug()  : void
Log a debug message.
extractTextDomain()  : array<string|int, mixed>
Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.
failOverToNoILS()  : bool
If configured, fail over to the NoILS driver and return true; otherwise, return false.
getDebugTranslation()  : string
Build a debug-mode translation
getHelpText()  : string
Get proper help text from the function config
hasNoILSFailover()  : bool
Are we configured to fail over to the NoILS driver on error?
initializeDriver()  : void
Initialize the ILS driver.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
sanitizeTranslationKey()  : string
Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.
translateString()  : string
Get translation for a string

Properties

$config

ILS configuration

protected Config $config

$driver

The object of the appropriate driver.

protected object $driver = null

$driverInitialized

Has the driver been initialized yet?

protected bool $driverInitialized = false

$failing

Is the current ILS driver failing?

protected bool $failing = false

$holdsMode

Holds mode

protected string $holdsMode = 'disabled'

$request

Request object

protected Request $request

$titleHoldsMode

Title-level holds mode

protected string $titleHoldsMode = 'disabled'

Methods

__call()

Default method -- pass along calls to the driver if available; return false otherwise. This allows custom functions to be implemented in the driver without constant modification to the connection class.

public __call(string $methodName, array<string|int, mixed> $params) : mixed
Parameters
$methodName : string

The name of the called method.

$params : array<string|int, mixed>

Array of passed parameters.

Tags
throws
ILS
Return values
mixed

Varies by method (false if undefined method)

__construct()

Constructor

public __construct(Config $config, PluginManager $driverManager, PluginManager $configReader[, Request $request = null ]) : mixed
Parameters
$config : Config

Configuration representing the [Catalog] section of config.ini

$driverManager : PluginManager

Driver plugin manager

$configReader : PluginManager

Configuration loader

$request : Request = null

Request object

Return values
mixed

checkCapability()

Check driver capability -- return true if the driver supports the specified method; false otherwise.

public checkCapability(string $method[, array<string|int, mixed> $params = [] ][, bool $throw = false ]) : bool
Parameters
$method : string

Method to check

$params : array<string|int, mixed> = []

Array of passed parameters (optional)

$throw : bool = false

Whether to throw exceptions instead of returning false

Tags
throws
ILS
Return values
bool

checkFunction()

Check Function

public checkFunction(string $function[, array<string|int, mixed> $params = null ]) : mixed

This is responsible for checking the driver configuration to determine if the system supports a particular function.

Parameters
$function : string

The name of the function to check.

$params : array<string|int, mixed> = null

(optional) An array of function-specific parameters

Return values
mixed

On success, an associative array with specific function keys and values; on failure, false.

checkILLRequestIsValid()

Check ILL Request is Valid

public checkILLRequestIsValid(string $id, array<string|int, mixed> $data, array<string|int, mixed> $patron) : mixed

This is responsible for checking if an ILL request is valid

Parameters
$id : string

A Bibliographic ID

$data : array<string|int, mixed>

Collected Holds Data

$patron : array<string|int, mixed>

Patron related data

Return values
mixed

The result of the checkILLRequestIsValid function if it exists, false if it does not

checkRequestIsValid()

Check Request is Valid

public checkRequestIsValid(string $id, array<string|int, mixed> $data, array<string|int, mixed> $patron) : mixed

This is responsible for checking if a request is valid from hold.php

Parameters
$id : string

A Bibliographic ID

$data : array<string|int, mixed>

Collected Holds Data

$patron : array<string|int, mixed>

Patron related data

Return values
mixed

The result of the checkRequestIsValid function if it exists, true if it does not

checkStorageRetrievalRequestIsValid()

Check Storage Retrieval Request is Valid

public checkStorageRetrievalRequestIsValid(string $id, array<string|int, mixed> $data, array<string|int, mixed> $patron) : mixed

This is responsible for checking if a storage retrieval request is valid

Parameters
$id : string

A Bibliographic ID

$data : array<string|int, mixed>

Collected Holds Data

$patron : array<string|int, mixed>

Patron related data

Return values
mixed

The result of the checkStorageRetrievalRequestIsValid function if it exists, false if it does not

getDriver()

Get access to the driver object.

public getDriver([bool $init = true ]) : object
Parameters
$init : bool = true

Should we initialize the driver (if necessary), or load it "as-is"?

Tags
throws
Exception
Return values
object

getDriverClass()

Get class name of the driver object.

public getDriverClass() : string
Return values
string

getDriverConfig()

Get configuration for the ILS driver. We will load an .ini file named after the driver class if it exists; otherwise we will return an empty array.

public getDriverConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHolding()

Get holdings

public getHolding(string $id[, array<string|int, mixed> $patron = null ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>

Retrieve holdings from ILS driver class and normalize result array and availability if needed.

Parameters
$id : string

The record id to retrieve the holdings for

$patron : array<string|int, mixed> = null

Patron data

$options : array<string|int, mixed> = []

Additional options

Return values
array<string|int, mixed>

Array with holding data

getHoldingsTextFieldNames()

Get Names of Textual Holdings Fields

public getHoldingsTextFieldNames() : array<string|int, string>

Obtain information on which textual holdings fields should be displayed

Return values
array<string|int, string>

getHoldsMode()

Get Holds Mode

public getHoldsMode() : string

This is responsible for returning the holds mode

Return values
string

The Holds mode

getMyTransactions()

Get Patron Transactions

public getMyTransactions(array<string|int, mixed> $patron[, array<string|int, mixed> $params = [] ]) : mixed

This is responsible for retrieving all transactions (i.e. checked out items) by a specific patron.

Parameters
$patron : array<string|int, mixed>

The patron array from patronLogin

$params : array<string|int, mixed> = []

Parameters

Return values
mixed

Array of the patron's transactions

getOfflineMode()

Get Offline Mode

public getOfflineMode([bool $healthCheck = false ]) : string|bool

This is responsible for returning the offline mode

Parameters
$healthCheck : bool = false

Perform a health check in addition to consulting the ILS status?

Return values
string|bool

"ils-offline" for systems where the main ILS is offline, "ils-none" for systems which do not use an ILS, false for online systems.

getPasswordPolicy()

Get the password policy from the driver

public getPasswordPolicy(array<string|int, mixed> $patron) : bool|array<string|int, mixed>
Parameters
$patron : array<string|int, mixed>

Patron data

Return values
bool|array<string|int, mixed>

Password policy array or false if unsupported

getStatus()

Get status

public getStatus(string $id) : array<string|int, mixed>

Retrieve status from ILS driver class and normalize availability if needed.

Parameters
$id : string

The record id to retrieve the status for

Return values
array<string|int, mixed>

Array with holding data

getStatuses()

Get statuses

public getStatuses(string $ids) : array<string|int, mixed>

Retrieve statuses from ILS driver class and normalize availability if needed.

Parameters
$ids : string

The record ids to retrieve the statuses for

Return values
array<string|int, mixed>

Array with holding data

getStatusParser()

Get a function that parses availability and status to an AvailabilityStatus object if necessary.

public getStatusParser() : callable
Return values
callable

getTitleHoldsMode()

Get Title Holds Mode

public getTitleHoldsMode() : string

This is responsible for returning the Title holds mode

Return values
string

The Title Holds mode

getTranslator()

Get translator object.

public getTranslator() : TranslatorInterface
Return values
TranslatorInterface

getTranslatorLocale()

Get the locale from the translator.

public getTranslatorLocale([string $default = 'en' ]) : string
Parameters
$default : string = 'en'

Default to use if translator absent.

Return values
string

hasHoldings()

Has Holdings

public hasHoldings(string $id) : bool

Obtain information on whether or not the item has holdings

Parameters
$id : string

A bibliographic id

Return values
bool

true on success, false on failure

loginIsHidden()

Get Hidden Login Mode

public loginIsHidden() : bool

This is responsible for indicating whether login should be hidden.

Return values
bool

true if the login should be hidden, false if not

setDriver()

Set a driver object.

public setDriver(DriverInterface $driver[, bool $initialized = false ]) : void
Parameters
$driver : DriverInterface

Driver to set.

$initialized : bool = false

Is this driver already initialized?

Return values
void

translate()

Translate a string (or string-castable object)

public translate(string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

translateWithPrefix()

Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.

public translateWithPrefix(string $prefix, string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$prefix : string

Translation key prefix

$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

checkMethodcancelHolds()

Check Cancel Holds

protected checkMethodcancelHolds(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports Cancelling Holds.

Parameters
$functionConfig : array<string|int, mixed>

The Cancel Hold configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values either for cancelling holds via a form or a URL; on failure, false.

checkMethodcancelILLRequests()

Check Cancel ILL Requests

protected checkMethodcancelILLRequests(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports Cancelling ILL Requests.

Parameters
$functionConfig : array<string|int, mixed>

The Cancel function configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values either for cancelling requests via a form or a URL; on failure, false.

checkMethodcancelStorageRetrievalRequests()

Check Cancel Storage Retrieval Requests

protected checkMethodcancelStorageRetrievalRequests(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports Cancelling Storage Retrieval Requests.

Parameters
$functionConfig : array<string|int, mixed>

The Cancel function configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values either for cancelling requests via a form or a URL; on failure, false.

checkMethodchangePassword()

Check Password Change

protected checkMethodchangePassword(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports changing password.

Parameters
$functionConfig : array<string|int, mixed>

The password change configuration values

$params : array<string|int, mixed>

Patron data

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values either for cancelling requests via a form or a URL; on failure, false.

checkMethodgetMyTransactionHistory()

Check Historic Loans

protected checkMethodgetMyTransactionHistory(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports historic loans.

Parameters
$functionConfig : array<string|int, mixed>

Function configuration

$params : array<string|int, mixed>

Patron data

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values; on failure, false.

checkMethodgetMyTransactions()

Check Current Loans

protected checkMethodgetMyTransactions(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports current loans.

Parameters
$functionConfig : array<string|int, mixed>

Function configuration

$params : array<string|int, mixed>

Patron data

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values; on failure, false.

checkMethodHolds()

Check Holds

protected checkMethodHolds(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports Holds.

Parameters
$functionConfig : array<string|int, mixed>

The Hold configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Return values
mixed

On success, an associative array with specific function keys and values either for placing holds via a form or a URL; on failure, false.

checkMethodILLRequests()

Check ILL Request

protected checkMethodILLRequests(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports storage retrieval requests.

Parameters
$functionConfig : array<string|int, mixed>

The ILL request configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Return values
mixed

On success, an associative array with specific function keys and values either for placing requests via a form; on failure, false.

checkMethodpatronLogin()

Check Patron login

protected checkMethodpatronLogin(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports patron login. It is currently assumed that all drivers do.

Parameters
$functionConfig : array<string|int, mixed>

The patronLogin configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Return values
mixed

On success, an associative array with specific function keys and values for login; on failure, false.

checkMethodpurgeTransactionHistory()

Check Purge Historic Loans

protected checkMethodpurgeTransactionHistory(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports purging of historic loans.

Parameters
$functionConfig : array<string|int, mixed>

Function configuration

$params : array<string|int, mixed>

Patron data

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values; on failure, false.

checkMethodRenewals()

Check Renewals

protected checkMethodRenewals(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports Renewing Items.

Parameters
$functionConfig : array<string|int, mixed>

The Renewal configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
mixed

On success, an associative array with specific function keys and values either for renewing items via a form or a URL; on failure, false.

checkMethodStorageRetrievalRequests()

Check Storage Retrieval Request

protected checkMethodStorageRetrievalRequests(array<string|int, mixed> $functionConfig, array<string|int, mixed> $params) : mixed

A support method for checkFunction(). This is responsible for checking the driver configuration to determine if the system supports storage retrieval requests.

Parameters
$functionConfig : array<string|int, mixed>

The storage retrieval request configuration values

$params : array<string|int, mixed>

An array of function-specific params (or null)

Return values
mixed

On success, an associative array with specific function keys and values either for placing requests via a form; on failure, false.

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

extractTextDomain()

Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.

protected extractTextDomain(string|object|array<string|int, mixed> $target) : array<string|int, mixed>
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

Return values
array<string|int, mixed>

failOverToNoILS()

If configured, fail over to the NoILS driver and return true; otherwise, return false.

protected failOverToNoILS([Exception $e = null ]) : bool
Parameters
$e : Exception = null

The exception that triggered the failover.

Return values
bool

getDebugTranslation()

Build a debug-mode translation

protected getDebugTranslation(string $domain, string $str, array<string|int, mixed> $tokens) : string
Parameters
$domain : string

Text domain

$str : string

String to translate

$tokens : array<string|int, mixed>

Tokens to inject into the translated string

Return values
string

getHelpText()

Get proper help text from the function config

protected getHelpText(string|array<string|int, mixed> $helpText) : string
Parameters
$helpText : string|array<string|int, mixed>

Help text(s)

Return values
string

Language-specific help text

hasNoILSFailover()

Are we configured to fail over to the NoILS driver on error?

protected hasNoILSFailover() : bool
Return values
bool

initializeDriver()

Initialize the ILS driver.

protected initializeDriver() : void
Return values
void

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

sanitizeTranslationKey()

Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.

protected sanitizeTranslationKey(string $key) : string
Parameters
$key : string

Key to sanitize

Return values
string

Sanitized key

translateString()

Get translation for a string

protected translateString(string $rawStr[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, string $domain = 'default' ][, bool $useIcuFormatter = false ]) : string
Parameters
$rawStr : string

String to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$domain : string = 'default'

Text domain (omit for default)

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

Return values
string

Search results