StorageHelper
in package
Uses
UtilsProvider
Helper functionality for common storage operations for a given consumer.
Table of Contents
Constants
- TABLE_NAME = 'template'
- TRANSIENT_CACHE_EXPIRE = 24 * 60 * 60
- TRANSIENT_CACHE_KEY = RCB_OPT_PREFIX . '-%s-templates-%s'
- TYPE_BLOCKER = 'blocker'
- TYPE_SERVICE = 'service'
Properties
- $expireOption : ExpireOption
- Cache of templates as they can be time-consuming to generate.
- $storage : mixed
Methods
- __construct() : mixed
- C'tor.
- fromArray() : mixed
- Convert JSON to `ServiceTemplate` or `BlockerTemplate` depending on current type.
- getCacheInvalidateKey() : mixed
- Automatically invalidate storage when Real Cookie Banner verion changes.
- getContext() : string
- Get context from variable resolver.
- getExpireOption() : mixed
- Get the `ExpireOption` instance.
- getPluginConstantPrefix() : string
- Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
- getType() : mixed
- Get type as string from template type class.
- persist() : mixed
- Persist a set of templates in chunks into the database.
- retrieveBy() : array<string|int, AbstractTemplate>|false
- Retrieve all templates (`field=null`) or by criteria.
- shouldInvalidate() : mixed
- updateOutdated() : mixed
- Update all `is_outdated` for all known services.
Constants
TABLE_NAME
public
mixed
TABLE_NAME
= 'template'
TRANSIENT_CACHE_EXPIRE
public
mixed
TRANSIENT_CACHE_EXPIRE
= 24 * 60 * 60
TRANSIENT_CACHE_KEY
public
mixed
TRANSIENT_CACHE_KEY
= RCB_OPT_PREFIX . '-%s-templates-%s'
TYPE_BLOCKER
public
mixed
TYPE_BLOCKER
= 'blocker'
TYPE_SERVICE
public
mixed
TYPE_SERVICE
= 'service'
Properties
$expireOption
Cache of templates as they can be time-consuming to generate.
private
ExpireOption
$expireOption
So, they are recalculated each x hours.
$storage
private
mixed
$storage
Methods
__construct()
C'tor.
public
__construct(AbstractStorage $storage) : mixed
Parameters
- $storage : AbstractStorage
fromArray()
Convert JSON to `ServiceTemplate` or `BlockerTemplate` depending on current type.
public
fromArray(array<string|int, mixed> $array) : mixed
Parameters
- $array : array<string|int, mixed>
getCacheInvalidateKey()
Automatically invalidate storage when Real Cookie Banner verion changes.
public
getCacheInvalidateKey() : mixed
getContext()
Get context from variable resolver.
public
getContext() : string
Return values
stringgetExpireOption()
Get the `ExpireOption` instance.
public
getExpireOption() : mixed
getPluginConstantPrefix()
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
public
getPluginConstantPrefix() : string
Tags
Return values
stringgetType()
Get type as string from template type class.
public
getType() : mixed
persist()
Persist a set of templates in chunks into the database.
public
persist(array<string|int, AbstractTemplate> $templates[, closre $otherMetaKeysResolver = null ]) : mixed
Parameters
- $templates : array<string|int, AbstractTemplate>
- $otherMetaKeysResolver : closre = null
retrieveBy()
Retrieve all templates (`field=null`) or by criteria.
public
retrieveBy([string $field = null ][, mixed $value = null ][, string $middlewareRoutine = 'after' ][, bool|string $forceInvalidate = false ]) : array<string|int, AbstractTemplate>|false
Parameters
- $field : string = null
- $value : mixed = null
- $middlewareRoutine : string = 'after'
-
Can be
before
orafter
- $forceInvalidate : bool|string = false
Return values
array<string|int, AbstractTemplate>|falseshouldInvalidate()
public
shouldInvalidate() : mixed
updateOutdated()
Update all `is_outdated` for all known services.
public
updateOutdated() : mixed