Facets
extends AbstractChannelProvider
in package
implements
TranslatorAwareInterface
Uses
TranslatorAwareTrait
Facet-driven channel provider.
Tags
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).
Table of Contents
- $coverRouter : Router
- Cover router
- $fields : array<string|int, mixed>
- Facet fields to use (field name => description).
- $maxFieldsToSuggest : int
- Maximum number of different fields to suggest in the channel list.
- $maxValuesToSuggestPerField : int
- Maximum number of values to suggest per field.
- $providerId : string
- Provider ID
- $recordRouter : Router
- Record router
- $resultsManager : PluginManager
- Search results manager.
- $translator : TranslatorInterface
- Translator
- $url : Url
- URL helper
- __construct() : mixed
- Constructor
- configureSearchParams() : void
- Hook to configure search parameters before executing search.
- getFromRecord() : array<string|int, mixed>
- Return channel information derived from a record driver object.
- getFromSearch() : array<string|int, mixed>
- Return channel information derived from a search results object.
- getTranslator() : TranslatorInterface
- Get translator object.
- getTranslatorLocale() : string
- Get the locale from the translator.
- setCoverRouter() : void
- Inject cover router
- setOptions() : void
- Set the options for the provider.
- setProviderId() : void
- Set an identifier that will be injected as the 'providerId' key of all channels created by this provider.
- setRecordRouter() : void
- Inject record router
- 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.
- buildChannel() : array<string|int, mixed>
- Add a new filter to an existing search results object to populate a channel.
- buildChannelFromFacet() : array<string|int, mixed>
- Call buildChannel using data from facet results.
- buildChannelFromToken() : array<string|int, mixed>
- Call buildChannel using data from a token.
- 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
- getToken() : string
- Turn a filter and title into a token.
- sanitizeTranslationKey() : string
- Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.
- summarizeRecordDrivers() : array<string|int, mixed>
- Convert a search results object into channel contents.
- translateString() : string
- Get translation for a string
Properties
$coverRouter
Cover router
protected
Router
$coverRouter
= null
$fields
Facet fields to use (field name => description).
protected
array<string|int, mixed>
$fields
$maxFieldsToSuggest
Maximum number of different fields to suggest in the channel list.
protected
int
$maxFieldsToSuggest
$maxValuesToSuggestPerField
Maximum number of values to suggest per field.
protected
int
$maxValuesToSuggestPerField
$providerId
Provider ID
protected
string
$providerId
= ''
$recordRouter
Record router
protected
Router
$recordRouter
= null
$resultsManager
Search results manager.
protected
PluginManager
$resultsManager
$translator
Translator
protected
TranslatorInterface
$translator
= null
$url
URL helper
protected
Url
$url
Methods
__construct()
Constructor
public
__construct(PluginManager $rm, Url $url[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $rm : PluginManager
-
Results manager
- $url : Url
-
URL helper
- $options : array<string|int, mixed> = []
-
Settings (optional)
Return values
mixed —configureSearchParams()
Hook to configure search parameters before executing search.
public
configureSearchParams(Params $params) : void
Parameters
- $params : Params
-
Search parameters to adjust
Return values
void —getFromRecord()
Return channel information derived from a record driver object.
public
getFromRecord(AbstractBase $driver[, string $channelToken = null ]) : array<string|int, mixed>
Parameters
- $driver : AbstractBase
-
Record driver
- $channelToken : string = null
-
Token identifying a single specific channel to load (if omitted, all channels will be loaded)
Return values
array<string|int, mixed> —getFromSearch()
Return channel information derived from a search results object.
public
getFromSearch(Results $results[, string $channelToken = null ]) : array<string|int, mixed>
Parameters
- $results : Results
-
Search results
- $channelToken : string = null
-
Token identifying a single specific channel to load (if omitted, all channels will be loaded)
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 —setCoverRouter()
Inject cover router
public
setCoverRouter(Router $coverRouter) : void
Parameters
- $coverRouter : Router
-
Cover router.
Return values
void —setOptions()
Set the options for the provider.
public
setOptions(array<string|int, mixed> $options) : void
Parameters
- $options : array<string|int, mixed>
-
Options
Return values
void —setProviderId()
Set an identifier that will be injected as the 'providerId' key of all channels created by this provider.
public
setProviderId(string $id) : void
Parameters
- $id : string
-
Provider ID
Return values
void —setRecordRouter()
Inject record router
public
setRecordRouter(Router $recordRouter) : void
Parameters
- $recordRouter : Router
-
Record router.
Return values
void —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 —buildChannel()
Add a new filter to an existing search results object to populate a channel.
protected
buildChannel(Results $results, string $filter, string $title[, bool $tokenOnly = false ]) : array<string|int, mixed>
Parameters
- $results : Results
-
Results object
- $filter : string
-
Filter to apply to Solr
- $title : string
-
Channel title
- $tokenOnly : bool = false
-
Create full channel (false) or return a token for future loading (true)?
Return values
array<string|int, mixed> —buildChannelFromFacet()
Call buildChannel using data from facet results.
protected
buildChannelFromFacet(Results $results, string $field, array<string|int, mixed> $value[, bool $tokenOnly = false ]) : array<string|int, mixed>
Parameters
- $results : Results
-
Results object
- $field : string
-
Field name (for filter)
- $value : array<string|int, mixed>
-
Field value information (for filter)
- $tokenOnly : bool = false
-
Create full channel (false) or return a token for future loading (true)?
Return values
array<string|int, mixed> —buildChannelFromToken()
Call buildChannel using data from a token.
protected
buildChannelFromToken(Results $results, string $token) : array<string|int, mixed>
Parameters
- $results : Results
-
Results object
- $token : string
-
Token to parse
Return values
array<string|int, mixed> —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 —getToken()
Turn a filter and title into a token.
protected
getToken(string $filter, string $title) : string
Parameters
- $filter : string
-
Filter to apply to Solr
- $title : string
-
Channel title
Return values
string —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
summarizeRecordDrivers()
Convert a search results object into channel contents.
protected
summarizeRecordDrivers(array<string|int, mixed>|Traversable $drivers) : array<string|int, mixed>
Parameters
- $drivers : array<string|int, mixed>|Traversable
-
Record drivers to summarize.
Return values
array<string|int, mixed> —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?