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

Class to represent a tool consumer. More...

Public Member Functions

 __construct ($key=null, $dataConnector=null, $autoEnable=false)
 Class constructor. More...
 
 initialize ()
 Initialise the tool consumer. More...
 
 initialise ()
 Initialise the tool consumer. More...
 
 save ()
 Save the tool consumer to the database. More...
 
 delete ()
 Delete the tool consumer from the database. More...
 
 getRecordId ()
 Get the tool consumer record ID. More...
 
 setRecordId ($id)
 Sets the tool consumer record ID. More...
 
 getKey ()
 Get the tool consumer key. More...
 
 setKey ($key)
 Set the tool consumer key. More...
 
 getDataConnector ()
 Get the data connector. More...
 
 getIsAvailable ()
 Is the consumer key available to accept launch requests? 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 ($simple=true)
 Get Tool Settings. More...
 
 setToolSettings ($settings=array())
 Perform a Tool Settings service request. More...
 
 signParameters ($url, $type, $version, $params)
 Add the OAuth signature to an LTI message. More...
 
 doServiceRequest ($service, $method, $format, $data)
 Perform a service request. More...
 

Static Public Member Functions

static addSignature ($endpoint, $consumerKey, $consumerSecret, $data, $method= 'POST', $type=null)
 Add the OAuth signature to an array of message parameters or to a header string. More...
 
static fromRecordId ($id, $dataConnector)
 Load the tool consumer from the database by its record ID. More...
 

Data Fields

 $name = null
 Local name of tool consumer. More...
 
 $secret = null
 Shared secret. More...
 
 $ltiVersion = null
 LTI version (as reported by last tool consumer connection). More...
 
 $consumerName = null
 Name of tool consumer (as reported by last tool consumer connection). More...
 
 $consumerVersion = null
 Tool consumer version (as reported by last tool consumer connection). More...
 
 $consumerGuid = null
 Tool consumer GUID (as reported by first tool consumer connection). More...
 
 $cssPath = null
 Optional CSS path (as reported by last tool consumer connection). More...
 
 $protected = false
 Whether the tool consumer instance is protected by matching the consumer_guid value in incoming requests. More...
 
 $enabled = false
 Whether the tool consumer instance is enabled to accept incoming connection requests. More...
 
 $enableFrom = null
 Date/time from which the the tool consumer instance is enabled to accept incoming connection requests. More...
 
 $enableUntil = null
 Date/time until which the tool consumer instance is enabled to accept incoming connection requests. More...
 
 $lastAccess = null
 Date of last connection from this tool consumer. More...
 
 $idScope = ToolProvider::ID_SCOPE_ID_ONLY
 Default scope to use when generating an Id value for a user. More...
 
 $defaultEmail = ''
 Default email address (or email domain) to use when no email address is provided for a user. 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.

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 19 of file ToolConsumer.php.

Constructor & Destructor Documentation

__construct (   $key = null,
  $dataConnector = null,
  $autoEnable = false 
)

Class constructor.

Parameters
string$keyConsumer key
DataConnector$dataConnectorA data connector object
boolean$autoEnabletrue if the tool consumers is to be enabled automatically (optional, default is false)

Definition at line 157 of file ToolConsumer.php.

References DataConnector\getDataConnector(), DataConnector\getRandomString(), and ToolConsumer\initialize().

Member Function Documentation

static addSignature (   $endpoint,
  $consumerKey,
  $consumerSecret,
  $data,
  $method = 'POST',
  $type = null 
)
static

Add the OAuth signature to an array of message parameters or to a header string.

Returns
mixed Array of signed message parameters or header string

Definition at line 513 of file ToolConsumer.php.

References ToolConsumer\$name, and OAuthRequest\from_consumer_and_token().

Referenced by ToolConsumer\doServiceRequest(), and Service\send().

delete ( )

Delete the tool consumer from the database.

Returns
boolean True if the object was successfully deleted

Definition at line 236 of file ToolConsumer.php.

doServiceRequest (   $service,
  $method,
  $format,
  $data 
)

Perform a service request.

Parameters
object$serviceService object to be executed
string$methodHTTP action
string$formatMedia type
mixed$dataArray of parameters or body string
Returns
HTTPMessage HTTP object containing request and response details

Definition at line 580 of file ToolConsumer.php.

References ToolConsumer\$secret, and ToolConsumer\addSignature().

static fromRecordId (   $id,
  $dataConnector 
)
static

Load the tool consumer from the database by its record ID.

Parameters
string$idThe consumer key record ID
DataConnector$dataConnectorDatabase connection object
Returns
object ToolConsumer The tool consumer object

Definition at line 605 of file ToolConsumer.php.

Referenced by ToolProxy\getConsumer(), Context\getConsumer(), and ResourceLink\getConsumer().

getDataConnector ( )

Get the data connector.

Returns
mixed Data connector object or string

Definition at line 296 of file ToolConsumer.php.

getIsAvailable ( )

Is the consumer key available to accept launch requests?

Returns
boolean True if the consumer key is enabled and within any date constraints

Definition at line 308 of file ToolConsumer.php.

References ToolConsumer\$enabled.

getKey ( )

Get the tool consumer key.

Returns
string Consumer key value

Definition at line 272 of file ToolConsumer.php.

Referenced by ToolConsumer\signParameters().

getRecordId ( )

Get the tool consumer record ID.

Returns
int Consumer record ID value

Definition at line 248 of file ToolConsumer.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 333 of file ToolConsumer.php.

References ToolConsumer\$name.

Referenced by ToolConsumer\getToolSettings(), ToolConsumer\hasToolSettingsService(), ToolConsumer\setSetting(), and ToolConsumer\setToolSettings().

getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 372 of file ToolConsumer.php.

References ToolConsumer\$settings.

getToolSettings (   $simple = true)

Get Tool Settings.

Parameters
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 430 of file ToolConsumer.php.

References ToolConsumer\getSetting().

hasToolSettingsService ( )

Check if the Tool Settings service is supported.

Returns
boolean True if this tool consumer supports the Tool Settings service

Definition at line 414 of file ToolConsumer.php.

References ToolConsumer\getSetting().

initialise ( )

Initialise the tool consumer.

Pseudonym for initialize().

Definition at line 207 of file ToolConsumer.php.

References ToolConsumer\initialize().

initialize ( )

Initialise the tool consumer.

Definition at line 176 of file ToolConsumer.php.

References ToolProvider\ID_SCOPE_ID_ONLY.

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

save ( )

Save the tool consumer to the database.

Returns
boolean True if the object was successfully saved

Definition at line 219 of file ToolConsumer.php.

Referenced by ToolConsumer\saveSettings().

saveSettings ( )

Save setting values.

Returns
boolean True if the settings were successfully saved

Definition at line 396 of file ToolConsumer.php.

References ToolConsumer\save().

setKey (   $key)

Set the tool consumer key.

Parameters
string$keyConsumer key value

Definition at line 284 of file ToolConsumer.php.

setRecordId (   $id)

Sets the tool consumer record ID.

Parameters
int$idConsumer record ID value

Definition at line 260 of file ToolConsumer.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 352 of file ToolConsumer.php.

References ToolConsumer\$name, and ToolConsumer\getSetting().

setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 384 of file ToolConsumer.php.

References ToolConsumer\$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 448 of file ToolConsumer.php.

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

signParameters (   $url,
  $type,
  $version,
  $params 
)

Add the OAuth signature to an LTI message.

Parameters
string$urlURL for message request
string$typeLTI message type
string$versionLTI version
array$paramsMessage parameters
Returns
array Array of signed message parameters

Definition at line 469 of file ToolConsumer.php.

References ToolConsumer\$name, OAuthRequest\from_consumer_and_token(), and ToolConsumer\getKey().

Field Documentation

string $consumerGuid = null

Tool consumer GUID (as reported by first tool consumer connection).

Definition at line 57 of file ToolConsumer.php.

string $consumerName = null

Name of tool consumer (as reported by last tool consumer connection).

Definition at line 45 of file ToolConsumer.php.

string $consumerVersion = null

Tool consumer version (as reported by last tool consumer connection).

Definition at line 51 of file ToolConsumer.php.

int $created = null

Date/time when the object was created.

Definition at line 117 of file ToolConsumer.php.

string $cssPath = null

Optional CSS path (as reported by last tool consumer connection).

Definition at line 63 of file ToolConsumer.php.

string $defaultEmail = ''

Default email address (or email domain) to use when no email address is provided for a user.

Definition at line 105 of file ToolConsumer.php.

boolean $enabled = false

Whether the tool consumer instance is enabled to accept incoming connection requests.

Definition at line 75 of file ToolConsumer.php.

Referenced by ToolConsumer\getIsAvailable().

int $enableFrom = null

Date/time from which the the tool consumer instance is enabled to accept incoming connection requests.

Definition at line 81 of file ToolConsumer.php.

int $enableUntil = null

Date/time until which the tool consumer instance is enabled to accept incoming connection requests.

Definition at line 87 of file ToolConsumer.php.

Default scope to use when generating an Id value for a user.

Definition at line 99 of file ToolConsumer.php.

int $lastAccess = null

Date of last connection from this tool consumer.

Definition at line 93 of file ToolConsumer.php.

string $ltiVersion = null

LTI version (as reported by last tool consumer connection).

Definition at line 39 of file ToolConsumer.php.

string $name = null

Local name of tool consumer.

Definition at line 27 of file ToolConsumer.php.

Referenced by ToolConsumer\addSignature(), ToolConsumer\getSetting(), ToolConsumer\setSetting(), and ToolConsumer\signParameters().

boolean $protected = false

Whether the tool consumer instance is protected by matching the consumer_guid value in incoming requests.

Definition at line 69 of file ToolConsumer.php.

string $secret = null

Shared secret.

Definition at line 33 of file ToolConsumer.php.

Referenced by ToolConsumer\doServiceRequest().

array $settings = null

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

Definition at line 111 of file ToolConsumer.php.

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

int $updated = null

Date/time when the object was last updated.

Definition at line 123 of file ToolConsumer.php.


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