Settings
in package
This is a class to provide access to the setting service.
There are three scopes of settings: link, context, and key The link level settings are by far the most widely used.
In effect, this should be deprecated and folks should use the methods in each entity.
A better pattern:
$LAUNCH = LTIX::requireData(); $LAUNCH->link->settingsSet('key', 'value');
But this is widely used in tool code so it will be hard to remove. At least now it wraps the Link settings.
Table of Contents
Methods
- getDebugArray() : mixed
- Retrieve the debug array for the last operation.
- linkDefaultConfigurationFromLaunch() : string|null
- Default link configuration from launch sources into Settings.
- linkGet() : mixed
- Retrieve a particular key from the link settings.
- linkGetAll() : mixed
- Retrieve an array of all of the link level settings
- linkGetCustom() : mixed
- Get a key value or fall back to a custom value in the launch
- linkSet() : mixed
- Set or update a key to a new value in link settings.
- linkSetAll() : mixed
- Set all of the the link-level settings.
- linkUpdate() : mixed
- Set or update a number of keys to new values in link settings.
Methods
getDebugArray()
Retrieve the debug array for the last operation.
public
static getDebugArray() : mixed
linkDefaultConfigurationFromLaunch()
Default link configuration from launch sources into Settings.
public
static linkDefaultConfigurationFromLaunch(string $key[, array<string|int, mixed>|null $allowed = null ]) : string|null
Opt-in helper for tools that want a placement setting defaulted on first launch from LTI custom or ?key=. Once defaulted, later launches use Settings and no longer depend on custom or GET.
Precedence:
- Link Settings (already configured) — when $LINK is present
- LTI custom for $key (persisted when present) — when $LINK/$LAUNCH
- $_GET[$key] (persisted when $LINK is present)
When $LINK is not defined (non-LTI / standalone use), Settings and custom are skipped and a present GET value is returned without persistence so tools can still run outside an LTI launch.
When $allowed is provided, empty, "0", false, or any value not in $allowed is treated as unset and does not block later sources. Invalid values are never persisted. When $allowed is omitted, no validity checking is done — any present value is accepted and persisted.
Parameters
- $key : string
-
Setting / custom / GET parameter name
- $allowed : array<string|int, mixed>|null = null
-
Optional list of valid values (values, not labels)
Return values
string|nulllinkGet()
Retrieve a particular key from the link settings.
public
static linkGet(mixed $key[, mixed $default = false ]) : mixed
Returns the value found in settings or false if the key was not found.
Parameters
- $key : mixed
-
- The key to get from the settings.
- $default : mixed = false
-
- What to return if the key is not present
linkGetAll()
Retrieve an array of all of the link level settings
public
static linkGetAll() : mixed
If there are no settings, return an empty array.
This routine also looks for legacy custom fields and treats them as defaults for settings if the corresponding key is not already present in settings. This will slowly convert LTI 1.x custom parameters under the control of the LMS to LTI 2.x style settings under control of our local tools.
linkGetCustom()
Get a key value or fall back to a custom value in the launch
public
static linkGetCustom(mixed $key) : mixed
Parameters
- $key : mixed
Tags
linkSet()
Set or update a key to a new value in link settings.
public
static linkSet(mixed $key, mixed $value) : mixed
Parameters
- $key : mixed
- $value : mixed
Tags
linkSetAll()
Set all of the the link-level settings.
public
static linkSetAll(mixed $keyvals) : mixed
Parameters
- $keyvals : mixed
-
An array of key/value pairs that is serialized in JSON and stored. If this is an empty array, this effectively empties out all the settings.
linkUpdate()
Set or update a number of keys to new values in link settings.
public
static linkUpdate(mixed $keyvals) : mixed
Parameters
- $keyvals : mixed