Profile
extends Entity
in package
Site profile for a Google-login (or similarly linked) user.
Every Launch carries a Profile object after LTIX::buildLaunch(). When no site profile is linked (typical Canvas launch), $id is 0, $premium is 0, and isLinked() is false — but isPremium() and provider helpers are safe to call without null checks.
Billing integrations store per-provider metadata in the premium_json column (getPremiumJson(), setPremiumJson()). Top-level keys are provider ids (e.g. "stripe"); each value is that provider's object:
{"stripe":{"customer_id":"cus_...","subscription_id":"sub_..."},"paypal":{...}}
$premium is a tier level: 0 = no premium, 1 = base tier, higher = richer tiers.
User-facing preferences (theme, map, etc.) use the profile json column via JsonTrait; premium_json is for subscription / payment metadata only. JSON columns are not public object attributes so they are not exposed by var_dump / debug logging.
Table of Contents
Properties
- $id : mixed
- Primary key in the profile table (0 when no profile is linked).
- $launch : mixed
- A reference to our containing launch
- $premium : mixed
- Premium tier level (0 = none, 1+ = active tier).
- $premium_at : mixed
- When premium access became active (NULL if never premium).
- $ENTITY_NAME : mixed
- $PRIMARY_KEY : mixed
- $TABLE_NAME : mixed
- $premium_json : string|false|null
- Cached premium_json column value. false = not loaded yet.
Methods
- __debugInfo() : array<string, mixed>
- fromLaunchRow() : self
- Build a Profile from the LTI session row.
- 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)
- getPremiumJson() : string|false
- Read the raw premium_json column for this profile.
- getPremiumJsonArray() : array<string, mixed>
- Decode premium_json to an associative array (provider id => provider data).
- getPremiumLevel() : int
- Current premium tier (always >= 0).
- getPremiumProviderArray() : array<string, mixed>
- Provider-specific metadata object from premium_json.
- getPremiumProviderKey() : mixed
- Read a key from one provider's block in premium_json.
- hasPremiumProvider() : bool
- Whether premium_json has a block for the given provider.
- isLinked() : bool
- True when this launch is linked to a row in the profile table.
- isPremium() : bool
- True when the profile has any premium tier (level >= 1).
- isPremiumLevel() : bool
- True when the profile meets at least the requested tier.
- ltiCustomGet() : mixed
- Pull out a custom variable from the LTIX session. Do not include the "custom_" prefix - this is automatic.
- ltiParameter() : mixed
- Pull a keyed variable from the original LTI post data in the current session with default
- ltiParameterUpdate() : mixed
- Update a keyed variable from the original LTI post data in the current session with default
- ltiRawParameter() : mixed
- Pull a keyed variable from the original LTI post data in the current session with default
- ltiRawPostArray() : mixed
- Return the original $_POST array
- normalizePremiumLevel() : int
- 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
- setPremiumJson() : mixed
- Write the premium_json column for this profile.
- loadPremiumFromDatabase() : mixed
- Load premium columns from the profile table (Google login and other non-LTI paths).
- loadPremiumJsonFromDatabase() : mixed
- Load only premium_json from the profile table.
- setPremiumJsonMemory() : mixed
- Cache premium_json in memory without writing to the database.
Properties
$id
Primary key in the profile table (0 when no profile is linked).
public
mixed
$id
= 0
$launch
A reference to our containing launch
public
mixed
$launch
$premium
Premium tier level (0 = none, 1+ = active tier).
public
mixed
$premium
= 0
$premium_at
When premium access became active (NULL if never premium).
public
mixed
$premium_at
= null
$ENTITY_NAME
protected
mixed
$ENTITY_NAME
= "profile"
$PRIMARY_KEY
protected
mixed
$PRIMARY_KEY
= "profile_id"
$TABLE_NAME
protected
mixed
$TABLE_NAME
= "profile"
$premium_json
Cached premium_json column value. false = not loaded yet.
private
string|false|null
$premium_json
= false
Methods
__debugInfo()
public
__debugInfo() : array<string, mixed>
Return values
array<string, mixed>fromLaunchRow()
Build a Profile from the LTI session row.
public
static fromLaunchRow(array<string, mixed> $LTI, Launch $launch) : self
Always returns a Profile. When profile_id is missing, returns an empty placeholder (id 0, premium 0, no providers).
Parameters
- $LTI : array<string, mixed>
- $launch : Launch
Return values
selfgetJson()
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)
getPremiumJson()
Read the raw premium_json column for this profile.
public
getPremiumJson() : string|false
Return values
string|false —JSON string, or false when empty / not set
getPremiumJsonArray()
Decode premium_json to an associative array (provider id => provider data).
public
getPremiumJsonArray() : array<string, mixed>
Return values
array<string, mixed>getPremiumLevel()
Current premium tier (always >= 0).
public
getPremiumLevel() : int
Return values
intgetPremiumProviderArray()
Provider-specific metadata object from premium_json.
public
getPremiumProviderArray(string $provider) : array<string, mixed>
Parameters
- $provider : string
-
Provider id (e.g. "stripe")
Return values
array<string, mixed>getPremiumProviderKey()
Read a key from one provider's block in premium_json.
public
getPremiumProviderKey(string $provider, string $key[, mixed $default = false ]) : mixed
Parameters
- $provider : string
-
Provider id (e.g. "stripe")
- $key : string
- $default : mixed = false
hasPremiumProvider()
Whether premium_json has a block for the given provider.
public
hasPremiumProvider(string $provider) : bool
Parameters
- $provider : string
-
Provider id (e.g. "stripe")
Return values
boolisLinked()
True when this launch is linked to a row in the profile table.
public
isLinked() : bool
Return values
boolisPremium()
True when the profile has any premium tier (level >= 1).
public
isPremium() : bool
Return values
boolisPremiumLevel()
True when the profile meets at least the requested tier.
public
isPremiumLevel(int $level) : bool
Parameters
- $level : int
-
Minimum tier required (1 = base premium)
Return values
boolltiCustomGet()
Pull out a custom variable from the LTIX session. Do not include the "custom_" prefix - this is automatic.
public
ltiCustomGet(mixed $varname[, mixed $default = false ]) : mixed
Parameters
- $varname : mixed
- $default : mixed = false
ltiParameter()
Pull a keyed variable from the original LTI post data in the current session with default
public
ltiParameter(mixed $varname[, mixed $default = false ]) : mixed
Parameters
- $varname : mixed
- $default : mixed = false
ltiParameterUpdate()
Update a keyed variable from the original LTI post data in the current session with default
public
ltiParameterUpdate(mixed $varname, mixed $value) : mixed
Parameters
- $varname : mixed
- $value : mixed
ltiRawParameter()
Pull a keyed variable from the original LTI post data in the current session with default
public
ltiRawParameter(mixed $varname[, mixed $default = false ]) : mixed
Parameters
- $varname : mixed
- $default : mixed = false
ltiRawPostArray()
Return the original $_POST array
public
ltiRawPostArray() : mixed
normalizePremiumLevel()
public
static normalizePremiumLevel(mixed $value) : int
Parameters
- $value : mixed
Return values
intsetJson()
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
setPremiumJson()
Write the premium_json column for this profile.
public
setPremiumJson(string|false|null $json) : mixed
Parameters
- $json : string|false|null
-
Raw JSON string (no validation)
loadPremiumFromDatabase()
Load premium columns from the profile table (Google login and other non-LTI paths).
protected
loadPremiumFromDatabase() : mixed
loadPremiumJsonFromDatabase()
Load only premium_json from the profile table.
protected
loadPremiumJsonFromDatabase() : mixed
setPremiumJsonMemory()
Cache premium_json in memory without writing to the database.
private
setPremiumJsonMemory(string|false|null $json) : mixed
Parameters
- $json : string|false|null