ServiceStorage
extends AbstractStorage
in package
This storage persists and reads service templates from `wp_rcb_template` database table.
The database table itself does not reflect all available properties in own columsn, instead only the important one. The complete template JSON will be saved in a serialized column so it can be restored.
Table of Contents
Properties
Methods
- __construct() : mixed
- C'tor.
- getConsumer() : mixed
- Getter.
- getHelper() : mixed
- Getter.
- persist() : void
- Persist all templates to storage (e.g. save to filesystem, redis or database).
- retrieve() : array<string|int, AbstractTemplate>|false
- Retrieve all templates from storage (e.g. request from filesystem, redis or database).
- retrieveBy() : array<string|int, AbstractTemplate>|false
- Get a single template instance by criteria.
- shouldInvalidate() : bool
- Check if the storage should be invalidated (e.g. after 24 hours). We highly recommend to return the database as source of truth by e.g. returning the result of `UPDATE` to avoid race conditions.
Properties
$consumer
private
mixed
$consumer
$helper
private
mixed
$helper
Methods
__construct()
C'tor.
public
__construct(ServiceCloudConsumer $consumer) : mixed
Parameters
- $consumer : ServiceCloudConsumer
getConsumer()
Getter.
public
getConsumer() : mixed
Tags
getHelper()
Getter.
public
getHelper() : mixed
persist()
Persist all templates to storage (e.g. save to filesystem, redis or database).
public
persist(mixed $templates) : void
Parameters
- $templates : mixed
retrieve()
Retrieve all templates from storage (e.g. request from filesystem, redis or database).
public
retrieve(mixed $forceInvalidate) : array<string|int, AbstractTemplate>|false
Return false
if data needs to be retrieved from data sources again.
Parameters
- $forceInvalidate : mixed
-
See
ServiceCloudConsumer#retrieveBy
parameters
Return values
array<string|int, AbstractTemplate>|false —Return false
if the storage does not know about any templates
so data sources are used to retrieve data. Afterwards, this is called again.
retrieveBy()
Get a single template instance by criteria.
public
retrieveBy(mixed $field, mixed $value, mixed $forceInvalidate) : array<string|int, AbstractTemplate>|false
Predefined $field
and $value
schemas which you should receive to make it work with all our middlewares:
ResolveServiceTemplatesMiddleware
$field = `identifier`
$value = string
VersionsMiddleware
$field = `versions`
$value = [string (identifier), ...number]
Parameters
- $field : mixed
-
Can be
identifier
, or whatever you want to implement to receive templates - $value : mixed
- $forceInvalidate : mixed
-
See
ServiceCloudConsumer#retrieveBy
parameters
Return values
array<string|int, AbstractTemplate>|false —Return false
if the storage does
not know about any templates so data sources are used to retrieve data. Afterwards,
this is called again.
shouldInvalidate()
Check if the storage should be invalidated (e.g. after 24 hours). We highly recommend to return the database as source of truth by e.g. returning the result of `UPDATE` to avoid race conditions.
public
shouldInvalidate() : bool