PersistTranslationsMiddlewareImpl
extends PersistTranslationsMiddleware
in package
Uses
UtilsProvider
Pool middleware for both service and blocker templates and persist translations to `wp_rcb_template_translation`.
Table of Contents
Constants
- CACHE_GROUP = RCB_OPT_PREFIX . '-template-translation'
- EXPAND_SKIP_KEYS = ['language', 'identifier', 'successorOfIdentifierInfo', 'enabledWhenOneOf', 'recommendedWhenOneOf', 'extendsIdentifier', 'status', 'createdAt', 'tier', 'logoUrl', 'consumerData', 'serviceTemplateIdentifiers', 'ruleGroups', 'rules', 'ruleNotice', 'visualType', 'visualContentType', 'shouldUncheckContentBlockerCheckboxWhenOneOf', 'codeOptIn', 'codeOptOut', 'codeOnPageLoad', 'tagManagerOptInEventName', 'tagManagerOptOutEventName', 'dynamicFields', 'dataProcessingInCountries', 'dataProcessingInCountriesSpecialTreatments', 'legalBasis', 'legalBasisNotice', 'group', 'technicalHandlingNotice', 'createContentBlockerNotice', 'groupNotice', 'providerNotice']
- Never create translations for this string-values.
- PERSIST_CHUNK_SIZE = 20
- TABLE_NAME = 'template_translation'
Properties
- $consumer : mixed
- $suspended : mixed
Methods
- __construct() : mixed
- C'tor.
- afterPersistTemplatesWithinPool() : void
- Override this functionality and misuse this hook to also download the latest GVL from the backend.
- beforePersistTemplateWithinPool() : void
- Before persisting the template instance when all consumers within a pool got downloaded.
- extractTranslations() : array<string|int, Translation>
- Extract translation instances from a set of templates.
- fetchEnglishTemplates() : mixed
- Fetch english templates as they should not be persisted to database.
- getConsumer() : mixed
- Getter.
- getPluginConstantPrefix() : string
- Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
- getVariableResolver() : mixed
- Getter.
- isSuspended() : mixed
- Check if the middleware is suspended.
- persistTranslations() : mixed
- Persist translations to your database or object cache or whatever.
- suspend() : mixed
- Allows to suspend or resume the middleware to take effect. This is efficient if a middleware could be called recursively.
Constants
CACHE_GROUP
public
mixed
CACHE_GROUP
= RCB_OPT_PREFIX . '-template-translation'
EXPAND_SKIP_KEYS
Never create translations for this string-values.
public
mixed
EXPAND_SKIP_KEYS
= ['language', 'identifier', 'successorOfIdentifierInfo', 'enabledWhenOneOf', 'recommendedWhenOneOf', 'extendsIdentifier', 'status', 'createdAt', 'tier', 'logoUrl', 'consumerData', 'serviceTemplateIdentifiers', 'ruleGroups', 'rules', 'ruleNotice', 'visualType', 'visualContentType', 'shouldUncheckContentBlockerCheckboxWhenOneOf', 'codeOptIn', 'codeOptOut', 'codeOnPageLoad', 'tagManagerOptInEventName', 'tagManagerOptOutEventName', 'dynamicFields', 'dataProcessingInCountries', 'dataProcessingInCountriesSpecialTreatments', 'legalBasis', 'legalBasisNotice', 'group', 'technicalHandlingNotice', 'createContentBlockerNotice', 'groupNotice', 'providerNotice']
PERSIST_CHUNK_SIZE
public
mixed
PERSIST_CHUNK_SIZE
= 20
TABLE_NAME
public
mixed
TABLE_NAME
= 'template_translation'
Properties
$consumer
private
mixed
$consumer
$suspended
private
mixed
$suspended
= false
Methods
__construct()
C'tor.
public
__construct(ServiceCloudConsumer $consumer) : mixed
Parameters
- $consumer : ServiceCloudConsumer
afterPersistTemplatesWithinPool()
Override this functionality and misuse this hook to also download the latest GVL from the backend.
public
afterPersistTemplatesWithinPool(array<string|int, ServiceCloudConsumer> $consumers, array<string|int, AbstractTemplate> &$typeClassToAllTemplates) : void
Parameters
- $consumers : array<string|int, ServiceCloudConsumer>
- $typeClassToAllTemplates : array<string|int, AbstractTemplate>
beforePersistTemplateWithinPool()
Before persisting the template instance when all consumers within a pool got downloaded.
public
abstract beforePersistTemplateWithinPool(AbstractTemplate $template, array<string|int, AbstractTemplate> &$typeClassToAllTemplates) : void
Example: Calculate contentBlockerTemplates
for ServiceTemplate
.
Parameters
- $template : AbstractTemplate
- $typeClassToAllTemplates : array<string|int, AbstractTemplate>
-
Key = type class, value = array of templates
extractTranslations()
Extract translation instances from a set of templates.
public
extractTranslations(array<string|int, AbstractTemplate> $templates, ServiceCloudConsumer $consumer) : array<string|int, Translation>
Parameters
- $templates : array<string|int, AbstractTemplate>
- $consumer : ServiceCloudConsumer
Return values
array<string|int, Translation>fetchEnglishTemplates()
Fetch english templates as they should not be persisted to database.
public
fetchEnglishTemplates(mixed $identifiers, mixed $consumer) : mixed
Parameters
- $identifiers : mixed
-
List of identifiers for which we want to the english templates
- $consumer : mixed
getConsumer()
Getter.
public
getConsumer() : mixed
Tags
getPluginConstantPrefix()
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
public
getPluginConstantPrefix() : string
Tags
Return values
stringgetVariableResolver()
Getter.
public
getVariableResolver() : mixed
Tags
isSuspended()
Check if the middleware is suspended.
public
isSuspended() : mixed
persistTranslations()
Persist translations to your database or object cache or whatever.
public
persistTranslations(mixed $translations, mixed $consumer) : mixed
Parameters
- $translations : mixed
- $consumer : mixed
suspend()
Allows to suspend or resume the middleware to take effect. This is efficient if a middleware could be called recursively.
public
suspend(bool $state) : mixed
Parameters
- $state : bool