Frontend
in package
Functions for the frontend (e.g. generating "Code on page load" HTML output).
Table of Contents
Constants
- COOKIE_NAME_SUFFIX_GCM = '-gcm'
- COOKIE_NAME_SUFFIX_TCF = '-tcf'
- COOKIE_NAME_USER_PREFIX = 'real_cookie_banner'
Properties
- $cookieConsentManagement : CookieConsentManagement
- See `CookieConsentManagement`.
Methods
- __construct() : mixed
- C'tor.
- generateCodeOnPageLoad() : array<string|int, string>
- Generate the "Code on page load" for all our configured services.
- getCookieConsentManagement() : mixed
- Getter.
- getCookieName() : mixed
- Get the cookie name for the consent decision.
- isInvalidateImplicitUserConsent() : mixed
- Determine if the implicit user consent should be invalidated when we visit a page which is configured to show the cookie banner in banner-less consent mode.
- isPreventPreDecision() : mixed
- Determine if the current page should not handle a predecision. See also `preDecisionGatewayIsPreventPreDecision`.
- persistedTransactionToJsonForHistoryViewer() : mixed
- Create a JSON object for the frontend so it can be shown as history. In general, we do not want to expose all data. And perhaps we need to modify some data before sending to the client. See also `BannerHistoryEntry` in `@devowl-wp/react-cookie-banner`.
- prepareLazyData() : mixed
- The `toJson` method prepares the data for the complete data of the frontend. Use this function to outsource lazy-loadable data for the second view in your cookie banner.
- toJson() : mixed
- Generate an array which can be used for the frontend to show the cookie banner / content blocker to the website visitor.
- generateGoogleConsentModeCodeOnPageLoad() : mixed
- Generate the code on page load for Google Consent Mode.
Constants
COOKIE_NAME_SUFFIX_GCM
public
mixed
COOKIE_NAME_SUFFIX_GCM
= '-gcm'
COOKIE_NAME_SUFFIX_TCF
public
mixed
COOKIE_NAME_SUFFIX_TCF
= '-tcf'
COOKIE_NAME_USER_PREFIX
public
mixed
COOKIE_NAME_USER_PREFIX
= 'real_cookie_banner'
Properties
$cookieConsentManagement
See `CookieConsentManagement`.
private
CookieConsentManagement
$cookieConsentManagement
Methods
__construct()
C'tor.
public
__construct(CookieConsentManagement $cookieConsentManagement) : mixed
Parameters
- $cookieConsentManagement : CookieConsentManagement
generateCodeOnPageLoad()
Generate the "Code on page load" for all our configured services.
public
generateCodeOnPageLoad([callable $outputModifier = null ]) : array<string|int, string>
Parameters
- $outputModifier : callable = null
-
Allows to modify the HTML output of a single service by a function
Return values
array<string|int, string>getCookieConsentManagement()
Getter.
public
getCookieConsentManagement() : mixed
Tags
getCookieName()
Get the cookie name for the consent decision.
public
getCookieName([string $suffix = '' ]) : mixed
Parameters
- $suffix : string = ''
-
See also constants starting with
COOKIE_NAME_SUFFIX_
isInvalidateImplicitUserConsent()
Determine if the implicit user consent should be invalidated when we visit a page which is configured to show the cookie banner in banner-less consent mode.
public
isInvalidateImplicitUserConsent([array<string|int, int> $pageIds = null ]) : mixed
Parameters
- $pageIds : array<string|int, int> = null
-
The current page IDs
isPreventPreDecision()
Determine if the current page should not handle a predecision. See also `preDecisionGatewayIsPreventPreDecision`.
public
isPreventPreDecision([array<string|int, int> $pageIds = null ]) : mixed
When returning true
, the cookie banner does not get shown and should use the existing consent if given, or fallback
to essentials
-only.
Parameters
- $pageIds : array<string|int, int> = null
-
The current page IDs
persistedTransactionToJsonForHistoryViewer()
Create a JSON object for the frontend so it can be shown as history. In general, we do not want to expose all data. And perhaps we need to modify some data before sending to the client. See also `BannerHistoryEntry` in `@devowl-wp/react-cookie-banner`.
public
persistedTransactionToJsonForHistoryViewer(PersistedTransaction $transaction) : mixed
Parameters
- $transaction : PersistedTransaction
prepareLazyData()
The `toJson` method prepares the data for the complete data of the frontend. Use this function to outsource lazy-loadable data for the second view in your cookie banner.
public
prepareLazyData(array<string|int, mixed> &$output[, bool $appendStateToOutput = false ]) : mixed
Parameters
- $output : array<string|int, mixed>
- $appendStateToOutput : bool = false
-
If
true
, ahasLazyData
property will be added to the passe$output
object
toJson()
Generate an array which can be used for the frontend to show the cookie banner / content blocker to the website visitor.
public
toJson() : mixed
Behind the scenes, it reuses Revision
where possible.
generateGoogleConsentModeCodeOnPageLoad()
Generate the code on page load for Google Consent Mode.
protected
generateGoogleConsentModeCodeOnPageLoad() : mixed