LTI Integration Library  3.1.0
PHP class library for building LTI integrations
Context Class Reference

Class to represent a tool consumer context. More...

Inheritance diagram for Context:
ApiHook

Public Member Functions

 __construct ()
 Class constructor. More...
 
 initialize ()
 Initialise the context. More...
 
 initialise ()
 Initialise the context. More...
 
 save ()
 Save the context to the database. More...
 
 delete ()
 Delete the context from the database. More...
 
 getConsumer ()
 Get tool consumer. More...
 
 setConsumerId ($consumerId)
 Set tool consumer ID. More...
 
 getKey ()
 Get tool consumer key. More...
 
 getId ()
 Get context ID. More...
 
 getRecordId ()
 Get the context record ID. More...
 
 setRecordId ($id)
 Sets the context record ID. More...
 
 getDataConnector ()
 Get the data connector. More...
 
 getSetting ($name, $default='')
 Get a setting value. More...
 
 setSetting ($name, $value=null)
 Set a setting value. More...
 
 getSettings ()
 Get an array of all setting values. More...
 
 setSettings ($settings)
 Set an array of all setting values. More...
 
 saveSettings ()
 Save setting values. More...
 
 hasToolSettingsService ()
 Check if the Tool Settings service is available. More...
 
 getToolSettings ($mode=Service\ToolSettings::MODE_CURRENT_LEVEL, $simple=true)
 Get Tool Settings. More...
 
 setToolSettings ($settings=array())
 Perform a Tool Settings service request. More...
 
 hasMembershipService ()
 Check if the Membership service is supported. More...
 
 hasMembershipsService ()
 Check if a Membership service is available. More...
 
 getMembership ()
 Get Membership. More...
 
 getMemberships ($withGroups=false)
 Get Memberships. More...
 

Static Public Member Functions

static fromRecordId ($id, $dataConnector)
 Load the context from the database. More...
 
static fromConsumer ($consumer, $ltiContextId)
 Class constructor from consumer. More...
 
- Static Public Member Functions inherited from ApiHook
static registerApiHook ($hookName, $familyCode, $className)
 Register the availability of an API hook. More...
 

Data Fields

 $ltiContextId = null
 Context ID as supplied in the last connection request. More...
 
 $title = null
 Context title. More...
 
 $type = null
 Context type. More...
 
 $groupSets = null
 UserResult group sets (null if the consumer does not support the groups enhancement) More...
 
 $groups = null
 UserResult groups (null if the consumer does not support the groups enhancement) More...
 
 $lastServiceRequest = null
 HTTPMessage object for last service request. More...
 
 $created = null
 Timestamp for when the object was created. More...
 
 $updated = null
 Timestamp for when the object was last updated. More...
 

Additional Inherited Members

- Static Public Attributes inherited from ApiHook
static $USER_ID_HOOK = "UserId"
 User Id hook name. More...
 
static $CONTEXT_ID_HOOK = "ContextId"
 Context Id hook name. More...
 
static $MEMBERSHIPS_SERVICE_HOOK = "Memberships"
 Memberships service hook name. More...
 
static $OUTCOMES_SERVICE_HOOK = "Outcomes"
 Outcomes service hook name. More...
 
static $TOOL_SETTINGS_SERVICE_HOOK = "ToolSettings"
 Tool Settings service hook name. More...
 

Detailed Description

Class to represent a tool consumer context.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Version
3.1.0
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Definition at line 17 of file Context.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Class constructor.

Definition at line 121 of file Context.php.

References Context\initialize().

Member Function Documentation

◆ delete()

delete ( )

Delete the context from the database.

Returns
bool True if the context was successfully deleted.

Definition at line 169 of file Context.php.

References Context\getDataConnector().

◆ fromConsumer()

static fromConsumer (   $consumer,
  $ltiContextId 
)
static

Class constructor from consumer.

Parameters
ToolConsumer$consumerConsumer instance
string$ltiContextIdLTI Context ID value
Returns
Context

Definition at line 484 of file Context.php.

References Context\$ltiContextId.

◆ fromRecordId()

static fromRecordId (   $id,
  $dataConnector 
)
static

Load the context from the database.

Parameters
int$idRecord ID of context
DataConnector$dataConnectorDatabase connection object
Returns
Context Context object

Definition at line 467 of file Context.php.

Referenced by ResourceLink\getContext().

◆ getConsumer()

getConsumer ( )

◆ getDataConnector()

getDataConnector ( )

Get the data connector.

Returns
mixed Data connector object or string

Definition at line 244 of file Context.php.

Referenced by Context\delete(), Context\getConsumer(), and Context\save().

◆ getId()

getId ( )

Get context ID.

Returns
string ID for this context.

Definition at line 214 of file Context.php.

References Context\$ltiContextId.

◆ getKey()

getKey ( )

Get tool consumer key.

Returns
string Consumer key value for this context.

Definition at line 204 of file Context.php.

References Context\getConsumer().

◆ getMembership()

getMembership ( )

Get Membership.

Deprecated:
Use getMemberships instead
See also
Context::getMemberships()
Returns
mixed The array of UserResult objects if successful, otherwise false

Definition at line 425 of file Context.php.

References Context\getMemberships().

◆ getMemberships()

getMemberships (   $withGroups = false)

Get Memberships.

Parameters
bool$withGroupsTrue is group information is to be requested as well
Returns
mixed The array of UserResult objects if successful, otherwise false

Definition at line 437 of file Context.php.

References Context\getConsumer(), and Context\getSetting().

Referenced by Context\getMembership().

◆ getRecordId()

getRecordId ( )

Get the context record ID.

Returns
int|null Context record ID value

Definition at line 224 of file Context.php.

◆ getSetting()

getSetting (   $name,
  $default = '' 
)

Get a setting value.

Parameters
string$nameName of setting
string$defaultValue to return if the setting does not exist (optional, default is an empty string)
Returns
string Setting value

Definition at line 257 of file Context.php.

Referenced by Context\getMemberships(), Context\getToolSettings(), Context\hasMembershipsService(), Context\hasToolSettingsService(), Context\setSetting(), and Context\setToolSettings().

◆ getSettings()

getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 292 of file Context.php.

◆ getToolSettings()

getToolSettings (   $mode = Service\ToolSettings::MODE_CURRENT_LEVEL,
  $simple = true 
)

Get Tool Settings.

Parameters
int$modeMode for request (optional, default is current level only)
bool$simpleTrue if all the simple media type is to be used (optional, default is true)
Returns
mixed The array of settings if successful, otherwise false

Definition at line 345 of file Context.php.

References Context\getConsumer(), and Context\getSetting().

◆ hasMembershipService()

hasMembershipService ( )

Check if the Membership service is supported.

Deprecated:
Use hasMembershipsService instead
See also
Context::hasMembershipsService()
Returns
bool True if this resource link supports the Membership service

Definition at line 398 of file Context.php.

References Context\hasMembershipsService().

◆ hasMembershipsService()

hasMembershipsService ( )

Check if a Membership service is available.

Returns
bool True if this context supports a Memberships service

Definition at line 408 of file Context.php.

References Context\getConsumer(), and Context\getSetting().

Referenced by Context\hasMembershipService().

◆ hasToolSettingsService()

hasToolSettingsService ( )

Check if the Tool Settings service is available.

Returns
bool True if this context supports the Tool Settings service

Definition at line 328 of file Context.php.

References Context\getConsumer(), and Context\getSetting().

◆ initialise()

initialise ( )

Initialise the context.

Pseudonym for initialize().

Definition at line 144 of file Context.php.

References Context\initialize().

◆ initialize()

initialize ( )

Initialise the context.

Definition at line 129 of file Context.php.

Referenced by Context\__construct(), and Context\initialise().

◆ save()

save ( )

Save the context to the database.

Returns
bool True if the context was successfully saved.

Definition at line 154 of file Context.php.

References Context\getDataConnector().

Referenced by Context\saveSettings().

◆ saveSettings()

saveSettings ( )

Save setting values.

Returns
bool True if the settings were successfully saved

Definition at line 312 of file Context.php.

References Context\save().

◆ setConsumerId()

setConsumerId (   $consumerId)

Set tool consumer ID.

Parameters
int$consumerIdTool Consumer ID for this resource link.

Definition at line 193 of file Context.php.

◆ setRecordId()

setRecordId (   $id)

Sets the context record ID.

Parameters
int$idContext record ID value

Definition at line 234 of file Context.php.

◆ setSetting()

setSetting (   $name,
  $value = null 
)

Set a setting value.

Parameters
string$nameName of setting
string$valueValue to set, use an empty value to delete a setting (optional, default is null)

Definition at line 274 of file Context.php.

References Context\getSetting().

◆ setSettings()

setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 302 of file Context.php.

◆ setToolSettings()

setToolSettings (   $settings = array())

Perform a Tool Settings service request.

Parameters
array$settingsAn associative array of settings (optional, default is none)
Returns
bool True if action was successful, otherwise false

Definition at line 372 of file Context.php.

References Context\getConsumer(), and Context\getSetting().

Field Documentation

◆ $created

int null $created = null

Timestamp for when the object was created.

Definition at line 67 of file Context.php.

◆ $groups

array null $groups = null

UserResult groups (null if the consumer does not support the groups enhancement)

Definition at line 53 of file Context.php.

◆ $groupSets

array null $groupSets = null

UserResult group sets (null if the consumer does not support the groups enhancement)

Definition at line 46 of file Context.php.

◆ $lastServiceRequest

HTTPMessage null $lastServiceRequest = null

HTTPMessage object for last service request.

Definition at line 60 of file Context.php.

◆ $ltiContextId

string null $ltiContextId = null

Context ID as supplied in the last connection request.

Definition at line 25 of file Context.php.

Referenced by Context\fromConsumer(), and Context\getId().

◆ $title

string null $title = null

Context title.

Definition at line 32 of file Context.php.

◆ $type

string null $type = null

Context type.

Definition at line 39 of file Context.php.

◆ $updated

int null $updated = null

Timestamp for when the object was last updated.

Definition at line 74 of file Context.php.


The documentation for this class was generated from the following file: