LTI Tool Provider Library  3.0.2
PHP class library for building LTI Tool Providers
Context Class Reference

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

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 supported. 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...
 
 getMembership ()
 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...
 

Data Fields

 $ltiContextId = null
 Context ID as supplied in the last connection request. More...
 
 $title = null
 Context title. More...
 
 $settings = null
 Setting values (LTI parameters, custom parameters and local parameters). More...
 
 $created = null
 Date/time when the object was created. More...
 
 $updated = null
 Date/time when the object was last updated. More...
 

Detailed Description

Class to represent a tool consumer context.

Author
Stephen P Vickers svick.nosp@m.ers@.nosp@m.imsgl.nosp@m.obal.nosp@m..org
Date
2016
Version
3.0.2
Licence:
http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0

Definition at line 17 of file Context.php.

Constructor & Destructor Documentation

__construct ( )

Class constructor.

Definition at line 85 of file Context.php.

References Context\initialize().

Member Function Documentation

delete ( )

Delete the context from the database.

Returns
boolean True if the context was successfully deleted.

Definition at line 139 of file Context.php.

References Context\getDataConnector().

static fromConsumer (   $consumer,
  $ltiContextId 
)
static

Class constructor from consumer.

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

Definition at line 425 of file Context.php.

References Context\$ltiContextId, Context\getDataConnector(), and Context\initialize().

Referenced by ToolProvider\onError().

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 407 of file Context.php.

Referenced by ResourceLink\getContext().

getConsumer ( )

Get tool consumer.

Returns
ToolConsumer Tool consumer object for this context.

Definition at line 151 of file Context.php.

References ToolConsumer\fromRecordId(), and Context\getDataConnector().

Referenced by Context\getKey().

getDataConnector ( )

Get the data connector.

Returns
mixed Data connector object or string

Definition at line 227 of file Context.php.

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

getId ( )

Get context ID.

Returns
string ID for this context.

Definition at line 191 of file Context.php.

References Context\$ltiContextId.

getKey ( )

Get tool consumer key.

Returns
string Consumer key value for this context.

Definition at line 179 of file Context.php.

References Context\getConsumer().

getMembership ( )

Get Memberships.

Returns
mixed The array of User objects if successful, otherwise false

Definition at line 388 of file Context.php.

References Context\getSetting().

getRecordId ( )

Get the context record ID.

Returns
int Context record ID value

Definition at line 203 of file Context.php.

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 242 of file Context.php.

Referenced by Context\getMembership(), Context\getToolSettings(), Context\hasMembershipService(), Context\hasToolSettingsService(), Context\setSetting(), and Context\setToolSettings().

getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 281 of file Context.php.

References Context\$settings.

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

Get Tool Settings.

Parameters
int$modeMode for request (optional, default is current level only)
boolean$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 340 of file Context.php.

References Context\getSetting().

hasMembershipService ( )

Check if the Membership service is supported.

Returns
boolean True if this context supports the Membership service

Definition at line 374 of file Context.php.

References Context\getSetting().

hasToolSettingsService ( )

Check if the Tool Settings service is supported.

Returns
boolean True if this context supports the Tool Settings service

Definition at line 323 of file Context.php.

References Context\getSetting().

initialise ( )

Initialise the context.

Pseudonym for initialize().

Definition at line 110 of file Context.php.

References Context\initialize().

initialize ( )

Initialise the context.

Definition at line 95 of file Context.php.

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

save ( )

Save the context to the database.

Returns
boolean True if the context was successfully saved.

Definition at line 122 of file Context.php.

References Context\getDataConnector().

Referenced by Context\saveSettings().

saveSettings ( )

Save setting values.

Returns
boolean True if the settings were successfully saved

Definition at line 305 of file Context.php.

References Context\save().

setConsumerId (   $consumerId)

Set tool consumer ID.

Parameters
int$consumerIdTool Consumer ID for this resource link.

Definition at line 166 of file Context.php.

setRecordId (   $id)

Sets the context record ID.

Returns
int $id Context record ID value

Definition at line 215 of file Context.php.

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 261 of file Context.php.

References Context\getSetting().

setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 293 of file Context.php.

References Context\$settings.

setToolSettings (   $settings = array())

Perform a Tool Settings service request.

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

Definition at line 358 of file Context.php.

References Context\$settings, and Context\getSetting().

Field Documentation

int $created = null

Date/time when the object was created.

Definition at line 43 of file Context.php.

string $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().

array $settings = null

Setting values (LTI parameters, custom parameters and local parameters).

Definition at line 37 of file Context.php.

Referenced by Context\getSettings(), Context\setSettings(), and Context\setToolSettings().

string $title = null

Context title.

Definition at line 31 of file Context.php.

int $updated = null

Date/time when the object was last updated.

Definition at line 49 of file Context.php.


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