Documentation

TemplateConsumers
in package
Uses UtilsProvider

Common service cloud consumer manager to consume local and external templates (e.g. service cloud).

It makes use of @devowl-wp/service-cloud-consumer.

Table of Contents

Constants

ONE_OF_PLUGIN_THEME_ACTIVE  = 'is-wordpress-plugin-or-theme-active:'
PERSIST_CHUNK_SIZE_TEMPLATES  = 30
Chunk templates to boost performance.

Properties

$me  : TemplateConsumers
Singleton instance.
$pools  : array<string|int, ConsumerPool>
All available consumers with key as context and value the `ConsumerPool`.

Methods

blockerCreated()  : mixed
Implementation of created content blocker.
createFromTemplate()  : mixed
Create or update a WordPress post from a given template.
currentForceRedownload()  : mixed
Force re-download from all datasources. This also includes download from the cloud API instead of "only" recalculating middlewares.
forceRecalculation()  : mixed
Force recalculation for middlewares (this does not necessarily download from cloud API!) for all blockers and services.
getContext()  : mixed
Get the context key for consumer pool. Its the language for which we request templates.
getCurrentBlockerConsumer()  : mixed
Shortcut to directly get the current context `ServiceConsumer`.
getCurrentPool()  : mixed
Get the service cloud consumer pool for the current context (e.g. WPML language).
getCurrentServiceConsumer()  : mixed
Shortcut to directly get the current context `ServiceConsumer`.
getInstance()  : mixed
Get singleton instance.
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
getPool()  : mixed
Get the service cloud consumer pool for a given current context (e.g. WPML language).
getTranslations()  : mixed
Get translations for a given target language (context). The source content is always english.
licenseStatusChanged()  : mixed
Delete all templates from storage except "Real Cookie Banner" template when license got deactivated.
oneOf()  : mixed
Implementation of `oneOf`.
probablyPersistTranslationsForRequestedLocales()  : mixed
Check for multiples locales template consumers if they need to be invalidated, invalidate them and persist the translations into database through the `PoolMiddleware`.
revisionCurrent()  : mixed
Add the release info of the latest cloud API template download.
servicesCreated()  : mixed
Implementation of created services.
tcfVendorsCreated()  : mixed
Implementation of `tcfVendors.created`.
translateInputFromTemplates()  : mixed
Translate strings from our template-translations table.
fillVariableResolver()  : mixed
Fill the variable resolver with our values.
__construct()  : mixed
C'tor.

Constants

ONE_OF_PLUGIN_THEME_ACTIVE

public mixed ONE_OF_PLUGIN_THEME_ACTIVE = 'is-wordpress-plugin-or-theme-active:'

PERSIST_CHUNK_SIZE_TEMPLATES

Chunk templates to boost performance.

public mixed PERSIST_CHUNK_SIZE_TEMPLATES = 30

But keep a bit lower, as service templates could be huge and feed the memory when doing join for preparing the SQL statement.

  • 50 is too much, first customers are running into issues with a Memory Limit of 128M

Properties

Methods

createFromTemplate()

Create or update a WordPress post from a given template.

public createFromTemplate(ServiceTemplate|BlockerTemplate $template[, array<string|int, int> $assignToTerm = null ][, int $updatePostId = null ][, array<string|int, string> $metaKeys = null ][, bool $updateVersion = true ]) : mixed
Parameters
$template : ServiceTemplate|BlockerTemplate
$assignToTerm : array<string|int, int> = null

The key of the array needs to be the taxonomy name

$updatePostId : int = null
$metaKeys : array<string|int, string> = null
$updateVersion : bool = true

currentForceRedownload()

Force re-download from all datasources. This also includes download from the cloud API instead of "only" recalculating middlewares.

public currentForceRedownload() : mixed

forceRecalculation()

Force recalculation for middlewares (this does not necessarily download from cloud API!) for all blockers and services.

public forceRecalculation() : mixed

getContext()

Get the context key for consumer pool. Its the language for which we request templates.

public static getContext() : mixed

getCurrentBlockerConsumer()

Shortcut to directly get the current context `ServiceConsumer`.

public static getCurrentBlockerConsumer() : mixed

getCurrentPool()

Get the service cloud consumer pool for the current context (e.g. WPML language).

public getCurrentPool() : mixed

getCurrentServiceConsumer()

Shortcut to directly get the current context `ServiceConsumer`.

public static getCurrentServiceConsumer() : mixed

getInstance()

Get singleton instance.

public static getInstance() : mixed
Tags
codeCoverageIgnore

getPluginConstantPrefix()

Get the prefix of this plugin so composer packages can dynamically build other constant values on it.

public getPluginConstantPrefix() : string
Tags
codeCoverageIgnore

It only returns a string with the constant prefix

Return values
string

getPool()

Get the service cloud consumer pool for a given current context (e.g. WPML language).

public getPool(string $context) : mixed
Parameters
$context : string

getTranslations()

Get translations for a given target language (context). The source content is always english.

public getTranslations(string $targetLanguage) : mixed

For performance reasons it makes use of the WordPress object cache.

It is sorted by newly-added translations first.

Parameters
$targetLanguage : string

licenseStatusChanged()

Delete all templates from storage except "Real Cookie Banner" template when license got deactivated.

public licenseStatusChanged(bool $status) : mixed

Otherwise, download from cloud API again.

Parameters
$status : bool

probablyPersistTranslationsForRequestedLocales()

Check for multiples locales template consumers if they need to be invalidated, invalidate them and persist the translations into database through the `PoolMiddleware`.

public probablyPersistTranslationsForRequestedLocales(array<string|int, string> $locales) : mixed
Parameters
$locales : array<string|int, string>

revisionCurrent()

Add the release info of the latest cloud API template download.

public revisionCurrent(array<string|int, mixed> $arr) : mixed
Parameters
$arr : array<string|int, mixed>

translateInputFromTemplates()

Translate strings from our template-translations table.

public translateInputFromTemplates(array<string|int, mixed> $translation, string $input, string $sourceLocale, string $targetLocale, string $domain) : mixed
Parameters
$translation : array<string|int, mixed>
$input : string
$sourceLocale : string
$targetLocale : string
$domain : string

        
On this page

Search results