BrowZine
in package
implements
DoiLinkerInterface, TranslatorAwareInterface
Uses
TranslatorAwareTrait
BrowZine DOI linker
Tags
Interfaces, Classes, Traits and Enums
- DoiLinkerInterface
- DOI linker interface
- 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).
Table of Contents
- $config : array<string|int, mixed>
- Configuration options
- $doiServices : array<string|int, mixed>
- Configured DOI services
- $searchService : Service
- Search service
- $translator : TranslatorInterface
- Translator
- __construct() : mixed
- Constructor
- getLinks() : array<string|int, mixed>
- Given an array of DOIs, perform a lookup and return an associative array of arrays, keyed by DOI. Each array contains one or more associative arrays with required 'link' (URL to related resource) and 'label' (display text) keys and an optional 'icon' (URL to icon graphic) or localIcon (name of configured icon in theme) key.
- getTranslator() : TranslatorInterface
- Get translator object.
- getTranslatorLocale() : string
- Get the locale from the translator.
- 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.
- arrayKeyAvailable() : bool
- Check if an array key is available in the data and allowed by filter settings.
- 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.
- getDebugTranslation() : string
- Build a debug-mode translation
- getDoiServices() : array<string|int, mixed>
- Get an array of DOI services and their configuration
- 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
Configuration options
protected
array<string|int, mixed>
$config
$doiServices
Configured DOI services
protected
array<string|int, mixed>
$doiServices
$searchService
Search service
protected
Service
$searchService
$translator
Translator
protected
TranslatorInterface
$translator
= null
Methods
__construct()
Constructor
public
__construct(Service $searchService[, array<string|int, mixed> $config = [] ][, array<string|int, mixed> $doiServices = [] ]) : mixed
Parameters
- $searchService : Service
-
Search service
- $config : array<string|int, mixed> = []
-
Configuration settings
- $doiServices : array<string|int, mixed> = []
-
Configured DOI services
Return values
mixed —getLinks()
Given an array of DOIs, perform a lookup and return an associative array of arrays, keyed by DOI. Each array contains one or more associative arrays with required 'link' (URL to related resource) and 'label' (display text) keys and an optional 'icon' (URL to icon graphic) or localIcon (name of configured icon in theme) key.
public
getLinks(array<string|int, mixed> $doiArray) : array<string|int, mixed>
Parameters
- $doiArray : array<string|int, mixed>
-
DOIs to look up
Return values
array<string|int, mixed> —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 —setTranslator()
Set a translator
public
setTranslator(TranslatorInterface $translator) : TranslatorAwareInterface
Parameters
- $translator : TranslatorInterface
-
Translator
Return values
TranslatorAwareInterface —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 —arrayKeyAvailable()
Check if an array key is available in the data and allowed by filter settings.
protected
arrayKeyAvailable(string $key, array<string|int, mixed> $data) : bool
Parameters
- $key : string
-
Key to check
- $data : array<string|int, mixed>
-
Available data
Return values
bool —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> —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 —getDoiServices()
Get an array of DOI services and their configuration
protected
getDoiServices() : array<string|int, mixed>
Return values
array<string|int, mixed> —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?