UserDataHashService

This service class contains functions related to hashing and data storage.
All public functions are available from the Twig template renderer.

Namespace

IO\Services

Properties
Type Name Description

DataBase

$db

``

$defaultTTL

Methods
public __construct($dataBase, $templateConfigService)

UserDataHashService constructor.

Parameters

Type

Name

Description

DataBase

$dataBase

TemplateConfigService

$templateConfigService

public find($hash, $contactId = null, $plentyId = null):UserDataHash

Get entry by hash if exists

Parameters

Type

Name

Description

string

$hash

The hash to search an entry for

int

$contactId

Optional: Restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

Optional: Use a specific plentyId. Otherwise use id of current client.

public findHash($type, $contactId = null, $plentyId = null):string

Get the hash of a specific type if exists and is not expired.

Parameters

Type

Name

Description

string

$type

The type to get the hash for

int

$contactId

Optional: Restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

Optional: Use a specific plentyId. Otherwise use id of current client.

public getData($hash, $contactId = null, $plentyId = null):mixed

Get the decoded data assigned to a hash

Parameters

Type

Name

Description

string

$hash

The hash to search an entry for

int

$contactId

Optional: Restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

Optional: Use a specific plentyId. Otherwise use id of current client.

public create($data, $type, $ttl = null, $contactId = null, $plentyId = null):UserDataHash

Create a new entry and assign data to the hash for later usage.

Parameters

Type

Name

Description

mixed

$data

The data to assign to the generated hash entry

string

$type

The type of the entry

int

$ttl

Optional: Lifetime of the hash entry in hours. Will get the value from config if not defined.

int

$contactId

Optional: Restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

Optional: Use a specific plentyId. Otherwise use id of current client.

public delete($hash, $contactId = null, $plentyId = null):bool

Remove a hash entry if exists.

Parameters

Type

Name

Description

string

$hash

The hash to search an entry for

int

$contactId

Optional: Restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

Optional: Use a specific plentyId. Otherwise use id of current client.

public deleteAll($type = null, $contactId = null, $plentyId = null):bool

Delete all entries

Parameters

Type

Name

Description

string

$type

Optional: Delete only entries for a specific type

int

$contactId

Optional: Restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

Optional: Use a specific plentyId. Otherwise use id of current client.