UserDataHashService

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

Optionally restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

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

Optionally restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

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

Optionally restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

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

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

int

$contactId

Optionally restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

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

Optionally restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

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

Optionally restrict results to a contact id. Otherwise use logged in contact

int

$plentyId

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