VariableResolver
in package
Allows to resolve variables and define if they are required or optional with a default.
It also allows to resolve variables by closure(VariableResolver $r)
instead of value.
Known variables (= [default] | * (required)
):
Consumer data
consumer.privacyPolicyUrl = * string
consumer.legalNoticeUrl = * string
consumer.provider = * string
consumer.providerContact.phone = * string
consumer.providerContact.email = * string
consumer.providerContact.link = * string
consumer.host.main = * string
consumer.host.main+subdomains = * string
consumer.host.current = * string
consumer.host.current+protocol = * string
consumer.host.current+subdomains = * string
template.fbPixel.scriptLocale = * Script locale used for Facebook pixel SDK js
Created templates
Array of existing / created blocker and services within the consumer environment. You do not need to fill all properties of the template object,
but consumerData['id']
and identifier
should be filled to make sure that the internal middlewares are working as expected.
created.{TemplateClass::class} = * TemplateClass[]
created.global.{TemplateClass::class} = * TemplateClass[]
tcfVendors.created = Array<{ vendorId: number; vendorConfigurationId: number; }>
What is the difference between created.
and created.global.
? In a consumer environment like e.g. WordPress and WPML as plugin installed,
created.
should only return the elements for the current language (current context). The created.global.
should return all entries across
all languages.
Misc
blocker.consumer = * Service cloud consumer for blocker templates
service.consumer = * Service cloud consumer for service templates
tier = * "free" | "pro"
manager = * "none" | "googleTagManager" | "googleTagManagerWithGcm" | "matomoTagManager"
serviceScan = Record<string (identifier), { foundCount: number; foundOnSitesCount: number; lastScanned: string; }>;
serviceScanIgnored = string[]
isTcfActive = boolean
One-of mechanism
Closure which needs to return boolean when the passed statement is fulfilled (e.g. checks if a setting or plugin is active).
When you return e.g. a string it will considered as fulfilled and replace the statement for the $fulfilledStatement
variable.
oneOf = * (statement: string, template?: AbstractTemplate) => false | true | mixed
Localization
i18n.disabled = "Disabled"
i18n.ContentTypeButtonTextMiddleware.loadContent = "Load content"
i18n.ContentTypeButtonTextMiddleware.loadMap = "Load map"
i18n.ContentTypeButtonTextMiddleware.loadForm = "Load form"
i18n.ExistsMiddleware.alreadyCreated = "Already created"
i18n.ExistsMiddleware.blockerAlreadyCreatedTooltip = "You have already created a Content Blocker with this template."
i18n.ExistsMiddleware.serviceAlreadyCreatedTooltip = "You have already created a Service (Cookie) with this template."
i18n.ManagerMiddleware.tooltip = "This service template is optimized to work with %s."
i18n.ManagerMiddleware.disabledTooltip = "Please activate %s in settings to use this template."
i18n.ServiceAvailableBlockerTemplatesMiddleware.tooltip = "A suitable content blocker for this service can be created automatically."
i18n.GroupMiddleware.group.essential = "Essential"
i18n.GroupMiddleware.group.functional = "Functional"
i18n.GroupMiddleware.group.statistics = "Statistics"
i18n.GroupMiddleware.group.marketing = "Marketing"
i18n.OneOfMiddleware.disabledTooltip = "This template is currently disabled because a dependency component is not installed or the desired function is not active."
i18n.TcfMiddleware.disabled = "TCF required"
i18n.TcfMiddleware.disabledTooltip = "This template requires the integration of TCF, as the provider of this template uses this standard. Please activate this in the settings to be able to block this service."
i18n.CdnMiddleware.introduction = "..."
i18n.CdnMiddleware.introductionNoScc = "..."
i18n.CdnMiddleware.introductionNotEssential = "..."
i18n.CdnMiddleware.introductionSccAndEmbedsOnlyExternalResources1 = "..."
i18n.CdnMiddleware.introductionSccAndEmbedsOnlyExternalResources2 = "..."
i18n.CdnMiddleware.introductionRemoveService = "..."
i18n.CdnMiddleware.moreInfoTitle = "..."
i18n.CdnMiddleware.moreInfoDescription = "..."
i18n.CdnMiddleware.sccConclusionInstructionsNoticeTitle = "..."
i18n.CdnMiddleware.buttonLabel = "..."
Table of Contents
Properties
- $consumer : mixed
- $data : array<string|int, mixed>
- Registered variable data.
- $resolvedCallableKeys : array<string|int, string>
- Callables should only be resolved once.
Methods
- __construct() : mixed
- C'tor.
- add() : mixed
- Add and register a variable with a given value.
- getConsumer() : mixed
- Getter.
- resolveDefault() : mixed
- Resolve a variable by key with a default value.
- resolveOneOf() : mixed
- Check an array of statements if one of them resolves truly with the required variable `oneOf`.
- resolveRequired() : mixed
- Resolve a variable by key and require it.
Properties
$consumer
private
mixed
$consumer
$data
Registered variable data.
private
array<string|int, mixed>
$data
= []
$resolvedCallableKeys
Callables should only be resolved once.
private
array<string|int, string>
$resolvedCallableKeys
= []
Methods
__construct()
C'tor.
public
__construct(ServiceCloudConsumer $consumer) : mixed
Parameters
- $consumer : ServiceCloudConsumer
add()
Add and register a variable with a given value.
public
add(string $key, mixed $value) : mixed
Parameters
- $key : string
- $value : mixed
-
Can be also a closure which gets called with the following arguments:
VariableResolver $resolver
getConsumer()
Getter.
public
getConsumer() : mixed
Tags
resolveDefault()
Resolve a variable by key with a default value.
public
resolveDefault(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
resolveOneOf()
Check an array of statements if one of them resolves truly with the required variable `oneOf`.
public
resolveOneOf(array<string|int, string> $statements, AbstractTemplate $template[, string &$fulfilledStatement = null ]) : mixed
Parameters
- $statements : array<string|int, string>
- $template : AbstractTemplate
- $fulfilledStatement : string = null
-
Automatically gets filled with the first fulfilled statement
resolveRequired()
Resolve a variable by key and require it.
public
resolveRequired(string $key) : mixed
Parameters
- $key : string