VuFind API Documentation

ObalkyKnihService
in package
implements HttpServiceAwareInterface, LoggerAwareInterface Uses HttpServiceAwareTrait, CacheTrait, LoggerAwareTrait

Service class for ObalkyKnih

Tags
category

VuFind

author

Josef Moravec moravec@mzk.cz

license

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

link

Wiki

Interfaces, Classes, Traits and Enums

HttpServiceAwareInterface
LoggerAwareInterface

Table of Contents

$baseUrls  : array<string|int, mixed>
Available base URLs
$cache  : StorageInterface
Cache for storing data temporarily (e.g. patron blocks with the ILS driver)
$cacheLifetime  : int
Lifetime of cache (in seconds).
$checkServersAvailability  : bool
Whether to check servers availability before API calls
$endpoints  : array<string|int, mixed>
Array with endpoints, possible endpoints(array keys) are: books, cover, toc, authority, citation, recommend, alive
$referrer  : string
Http referrer
$sigla  : string
Sigla - library identifier
__construct()  : mixed
Constructor
getData()  : stdClass|null
Get data from cache, or from service
setCacheStorage()  : void
Set a cache storage object.
createCacheKey()  : string
Creates cache key based on ids
createLocalIdentifier()  : string|null
Create identifier of local record
debug()  : void
Log a debug message.
getAliveUrl()  : string
Check base URLs and return the first available
getBaseUrl()  : string
Get currently available base URL
getCachedData()  : mixed|null
Helper function for fetching cached data.
getFromService()  : stdClass|null
Get data from service
getHttpClient()  : Client
Get an HTTP client
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

$baseUrls

Available base URLs

protected array<string|int, mixed> $baseUrls = []

$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

$checkServersAvailability

Whether to check servers availability before API calls

protected bool $checkServersAvailability = false

$endpoints

Array with endpoints, possible endpoints(array keys) are: books, cover, toc, authority, citation, recommend, alive

protected array<string|int, mixed> $endpoints

Methods

__construct()

Constructor

public __construct(Config $config) : mixed
Parameters
$config : Config

Configuration for service

Return values
mixed

getData()

Get data from cache, or from service

public getData(array<string|int, mixed> $ids) : stdClass|null
Parameters
$ids : array<string|int, mixed>

Record identifiers

Return values
stdClass|null

setCacheStorage()

Set a cache storage object.

public setCacheStorage([StorageInterface $cache = null ]) : void
Parameters
$cache : StorageInterface = null

Cache storage interface

Return values
void

createCacheKey()

Creates cache key based on ids

protected createCacheKey(array<string|int, mixed> $ids) : string
Parameters
$ids : array<string|int, mixed>

Record identifiers

Return values
string

createLocalIdentifier()

Create identifier of local record

protected createLocalIdentifier(string $recordid) : string|null
Parameters
$recordid : string

Record identifier

Return values
string|null

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

getAliveUrl()

Check base URLs and return the first available

protected getAliveUrl() : string
Return values
string

getBaseUrl()

Get currently available base URL

protected getBaseUrl() : string
Return values
string

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

getFromService()

Get data from service

protected getFromService(array<string|int, mixed> $ids) : stdClass|null
Parameters
$ids : array<string|int, mixed>

Record identifiers

Tags
throws
Exception
SuppressWarnings

(PHPMD.UnusedLocalVariable)

Return values
stdClass|null

getHttpClient()

Get an HTTP client

protected getHttpClient([string $url = null ]) : Client
Parameters
$url : string = null

URL for client to use

Return values
Client

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

Return values
void

Search results