Tsugi

JsonTrait

This is a class holding convienence methods to access the json column for the core objects.

This is a more general storage than the settings column.

Table of Contents

Methods

getJson()  : string
Load the json field for this entity
getJsonKey()  : mixed
Get a JSON key for this entity
getJsonKeyLegacy()  : mixed
Get a JSON key for this entity (legacy array style)
setJson()  : mixed
Set the JSON entry for this entity
setJsonKey()  : mixed
Set/update a JSON key for this entity
setJsonKeys()  : mixed
Set/update an array of JSON keys for this entity

Methods

getJson()

Load the json field for this entity

public getJson() : string
Return values
string —

This returns the json string - it is not parsed - if there is nothing to return - this returns "false"

getJsonKey()

Get a JSON key for this entity

public getJsonKey(mixed $key[, mixed $default = false ]) : mixed
Parameters
$key : mixed

The key to be retrieved from the JSON

$default : mixed = false

The default value (optional)

getJsonKeyLegacy()

Get a JSON key for this entity (legacy array style)

public getJsonKeyLegacy(mixed $key[, mixed $default = false ]) : mixed
Parameters
$key : mixed

The key to be retrieved from the JSON

$default : mixed = false

The default value (optional)

setJson()

Set the JSON entry for this entity

public setJson(mixed $json) : mixed
Parameters
$json : mixed

This is a string - no validation is done

setJsonKey()

Set/update a JSON key for this entity

public setJsonKey(mixed $key, mixed $value) : mixed
Parameters
$key : mixed

The key to be inserted/updated in the JSON

$value : mixed

The value to be inserted/updated in the JSON

setJsonKeys()

Set/update an array of JSON keys for this entity

public setJsonKeys(mixed $values) : mixed
Parameters
$values : mixed

An array of key/value pairs to be inserted/updated in the JSON


        
On this page

Search results