Connector
in package
implements
LoggerAwareInterface
Uses
LoggerAwareTrait
Central class for connecting to resources used by VuFind.
Tags
Interfaces, Classes, Traits and Enums
- LoggerAwareInterface
Table of Contents
- $base : string
- Base url for searches
- $client : Client
- The HTTP_Request object used for REST transactions
- $session : string
- Session ID
- __construct() : mixed
- Constructor
- bytarget() : array<string|int, mixed>
- Returns information about the status of each active client.
- init() : session
- Initializes a session. Returns session ID to be used in subsequent requests.
- ping() : void
- Keeps a session alive. An idle session will time out after one minute.
- record() : associative
- Retrieves a detailed record.
- search() : associative
- Launches a search.
- session() : session
- Return session id
- settings() : bool
- Applies settings to this session Each setting parameter has the form name[target]=value
- show() : array<string|int, mixed>
- Proper alias of results
- stat() : associative
- Provides status information about an ongoing search.
- termlist() : array<string|int, mixed>
- Retrieves term list(s).
- debug() : void
- Log a debug message.
- log() : void
- Send a message to the logger.
- logError() : void
- Log an error message.
- logWarning() : void
- Log a warning message.
- query() : SimpleXMLElement
- Requests and receives information from pazpar
- send() : string
- Send a request and return the response.
Properties
$base
Base url for searches
protected
string
$base
$client
The HTTP_Request object used for REST transactions
protected
Client
$client
$session
Session ID
protected
string
$session
= false
Methods
__construct()
Constructor
public
__construct(string $base, Client $client[, bool $autoInit = false ]) : mixed
Parameters
- $base : string
-
Base URL for Pazpar2
- $client : Client
-
An HTTP client object
- $autoInit : bool = false
-
Should we auto-initialize the Pazpar2 connection?
Return values
mixed —bytarget()
Returns information about the status of each active client.
public
bytarget(string $id) : array<string|int, mixed>
Parameters
- $id : string
-
client id
Return values
array<string|int, mixed> —Associative array of XML data
init()
Initializes a session. Returns session ID to be used in subsequent requests.
public
init() : session
Adds session to the base
Return values
session —id
ping()
Keeps a session alive. An idle session will time out after one minute.
public
ping() : void
The ping command can be used to keep the session alive absent other activity. It is suggested that any browser client have a simple alarm handler which sends a ping every 50 seconds or so once a session has been initialized
Return values
void —record()
Retrieves a detailed record.
public
record(string $id) : associative
Unlike the show command, this command returns metadata records before merging takes place.
Parameters
- $id : string
-
array of options as described above
Return values
associative —array of XML data
search()
Launches a search.
public
search([ParamBag $options = null ]) : associative
Option (default):
- query : search string ('')
- filter : setting+operator+args pairs, such as 'pz:id=4|17, pz:id~3'
- limit : Narrows the search by one or more fields (typically facets) as name=arg1|arg2| pairs separated by comma (none)
- startrecs : int (0)
- maxrecs : int (100)
TODO: Make the array more useful to get the correct format?
Parameters
- $options : ParamBag = null
-
array of options as described above
Return values
associative —array of XML data
session()
Return session id
public
session() : session
Return values
session —id
settings()
Applies settings to this session Each setting parameter has the form name[target]=value
public
settings([string $settings = false ]) : bool
TODO: Make the array more useful to get the correct format?
Parameters
- $settings : string = false
-
settings to be sets
Return values
bool —Success/failure status
show()
Proper alias of results
public
show([ParamBag $options = null ]) : array<string|int, mixed>
Options (default):
- start : int (0)
- num : int (20)
- block : 1 = wait until enough records are found (0)
- sort : column:1 [increasing] or 0 [decreasing] (none)
Parameters
- $options : ParamBag = null
-
array of options as described above
Return values
array<string|int, mixed> —Associative array of XML data
stat()
Provides status information about an ongoing search.
public
stat() : associative
Return values
associative —array of XML data
termlist()
Retrieves term list(s).
public
termlist([ParamBag $options = null ]) : array<string|int, mixed>
Options (default):
- name : comma-separated list of termlist names (all termlists)
- num : maximum number of entries to return (15)
Parameters
- $options : ParamBag = null
-
array of options as described above
Return values
array<string|int, mixed> —Associative array of XML data
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 —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 —query()
Requests and receives information from pazpar
protected
query(string $command[, ParamBag $data = null ]) : SimpleXMLElement
Parameters
- $command : string
-
the command to be executed
- $data : ParamBag = null
-
optional extra data
Return values
SimpleXMLElement —Response
send()
Send a request and return the response.
protected
send(Client $client) : string
Parameters
- $client : Client
-
Prepare HTTP client
Tags
Return values
string —Response body