ProxyUrl
extends AbstractHelper
in package
implements
LoggerAwareInterface, HttpServiceAwareInterface
Uses
CacheTrait, LoggerAwareTrait, HttpServiceAwareTrait
Proxy URL view helper
Tags
Interfaces, Classes, Traits and Enums
- LoggerAwareInterface
- HttpServiceAwareInterface
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).
- $config : Config
- VuFind configuration
- __construct() : mixed
- Constructor
- __invoke() : string
- Apply proxy prefix to URL (if configured).
- setCacheStorage() : void
- Set a cache storage object.
- checkConfig() : bool
- Return the configured prefixLinks setting.
- checkUrl() : mixed
- Check whether the given URL requires the proxy prefix. Cache the response.
- debug() : void
- Log a debug message.
- getCachedData() : mixed|null
- Helper function for fetching cached data.
- 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.
- queryWebService() : mixed
- Query the web service on whether to prefix URLs to a given domain.
- 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
$config
VuFind configuration
protected
Config
$config
Methods
__construct()
Constructor
public
__construct([Config $config = null ][, StorageInterface $cache = null ]) : mixed
Parameters
- $config : Config = null
-
VuFind configuration
- $cache : StorageInterface = null
-
Cache for web service responses
Return values
mixed —__invoke()
Apply proxy prefix to URL (if configured).
public
__invoke(string $url) : string
Parameters
- $url : string
-
The raw URL to adjust
Return values
string —setCacheStorage()
Set a cache storage object.
public
setCacheStorage([StorageInterface $cache = null ]) : void
Parameters
- $cache : StorageInterface = null
-
Cache storage interface
Return values
void —checkConfig()
Return the configured prefixLinks setting.
protected
checkConfig() : bool
Return values
bool —The configured setting, or the default
checkUrl()
Check whether the given URL requires the proxy prefix. Cache the response.
protected
checkUrl(string $url) : mixed
Parameters
- $url : string
-
The raw URL to check
Return values
mixed —Whether the URL should be prefixed, or null if it can't be determined
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
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 —queryWebService()
Query the web service on whether to prefix URLs to a given domain.
protected
queryWebService( $domain) : mixed
Parameters
Return values
mixed —Whether the URL should be prefixed, or null if it can't be determined
removeCachedData()
Helper function for removing cached data.
protected
removeCachedData(string $key) : void
Parameters
- $key : string
-
Cache entry key