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

Class to represent an LTI Tool Provider. More...

Inheritance diagram for ToolProvider:
ApiHook

Public Member Functions

 __construct ($dataConnector)
 Class constructor. More...
 
 handleRequest ()
 Process an incoming request. More...
 
 setParameterConstraint ($name, $required=true, $maxLength=null, $messageTypes=null)
 Add a parameter constraint to be checked on launch. More...
 
 getConsumers ()
 Get an array of defined tool consumers. More...
 
 findService ($format, $methods)
 Find an offered service based on a media type and HTTP action(s) More...
 
 doToolProxyService ()
 Send the tool proxy to the Tool Consumer. More...
 
 getMessageParameters ()
 Get the message parameters. More...
 

Static Public Member Functions

static parseRoles ($roles, $ltiVersion=self::LTI_VERSION1)
 Get an array of fully qualified user roles. More...
 
static sendForm ($url, $params, $target='')
 Generate a web page containing an auto-submitted form of parameters. More...
 
- Static Public Member Functions inherited from ApiHook
static registerApiHook ($hookName, $familyCode, $className)
 Register the availability of an API hook. More...
 

Data Fields

const CONNECTION_ERROR_MESSAGE = 'Sorry, there was an error connecting you to the application.'
 Default connection error message. More...
 
const LTI_VERSION1 = 'LTI-1p0'
 LTI version 1 for messages. More...
 
const LTI_VERSION2 = 'LTI-2p0'
 LTI version 2 for messages. More...
 
const ID_SCOPE_ID_ONLY = 0
 Use ID value only. More...
 
const ID_SCOPE_GLOBAL = 1
 Prefix an ID with the consumer key. More...
 
const ID_SCOPE_CONTEXT = 2
 Prefix the ID with the consumer key and context ID. More...
 
const ID_SCOPE_RESOURCE = 3
 Prefix the ID with the consumer key and resource ID. More...
 
const ID_SCOPE_SEPARATOR = ':'
 Character used to separate each element of an ID. More...
 
 $ok = true
 True if the last request was successful. More...
 
 $consumer = null
 Tool Consumer object. More...
 
 $returnUrl = null
 Return URL provided by tool consumer. More...
 
 $userResult = null
 UserResult object. More...
 
 $resourceLink = null
 Resource link object. More...
 
 $context = null
 Context object. More...
 
 $dataConnector = null
 Data connector object. More...
 
 $defaultEmail = ''
 Default email domain. More...
 
 $idScope = self::ID_SCOPE_ID_ONLY
 Scope to use for user IDs. More...
 
 $allowSharing = false
 Whether shared resource link arrangements are permitted. More...
 
 $message = self::CONNECTION_ERROR_MESSAGE
 Message for last request processed. More...
 
 $reason = null
 Error message for last request processed. More...
 
 $details = array()
 Details for error message relating to last request processed. More...
 
 $baseUrl = null
 Base URL for tool provider service. More...
 
 $vendor = null
 Vendor details. More...
 
 $product = null
 Product details. More...
 
 $requiredServices = null
 Services required by Tool Provider. More...
 
 $optionalServices = null
 Optional services used by Tool Provider. More...
 
 $resourceHandlers = null
 Resource handlers for Tool Provider. More...
 

Protected Member Functions

 onLaunch ()
 Process a valid launch request. More...
 
 onConfigure ()
 Process a valid configure request. More...
 
 onDashboard ()
 Process a valid dashboard request. More...
 
 onContentItem ()
 Process a valid content-item request. More...
 
 onRegister ()
 Process a valid tool proxy registration request. More...
 
 onError ()
 Process a response to an invalid request. More...
 

Protected Attributes

 $redirectUrl = null
 URL to redirect user to on successful completion of the request. More...
 
 $mediaTypes = null
 Media types accepted by the Tool Consumer. More...
 
 $documentTargets = null
 Document targets accepted by the Tool Consumer. More...
 
 $output = null
 Default HTML to be displayed on a successful completion of the request. More...
 
 $errorOutput = null
 HTML to be displayed on an unsuccessful completion of the request and no return URL is available. More...
 
 $debugMode = false
 Whether debug messages explaining the cause of errors are to be returned to the tool consumer. More...
 
 $messageParameters = null
 LTI message parameters. 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 an LTI Tool Provider.

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 20 of file ToolProvider.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $dataConnector)

Class constructor.

Parameters
DataConnector$dataConnectorObject containing a database connection object

Definition at line 332 of file ToolProvider.php.

References ToolProvider\$dataConnector.

Member Function Documentation

◆ doToolProxyService()

doToolProxyService ( )

Send the tool proxy to the Tool Consumer.

Returns
bool True if the tool proxy was accepted

Definition at line 425 of file ToolProvider.php.

References ToolProvider\$ok, ToolProvider\findService(), and DataConnector\getRandomString().

◆ findService()

findService (   $format,
  $methods 
)

Find an offered service based on a media type and HTTP action(s)

Parameters
string$formatMedia type required
array$methodsArray of HTTP actions required
Returns
object The service object

Definition at line 392 of file ToolProvider.php.

Referenced by ToolProvider\doToolProxyService().

◆ getConsumers()

getConsumers ( )

Get an array of defined tool consumers.

Returns
array Array of ToolConsumer objects

Definition at line 379 of file ToolProvider.php.

◆ getMessageParameters()

getMessageParameters ( )

Get the message parameters.

Returns
array The message parameter array

Definition at line 449 of file ToolProvider.php.

References ToolProvider\$messageParameters, OAuthRequest\$POST_INPUT, and OAuthUtil\parse_parameters().

Referenced by ToolProvider\handleRequest().

◆ handleRequest()

handleRequest ( )

Process an incoming request.

Definition at line 347 of file ToolProvider.php.

References ToolProvider\getMessageParameters().

◆ onConfigure()

onConfigure ( )
protected

Process a valid configure request.

Returns
bool True if no error

Definition at line 577 of file ToolProvider.php.

References ToolProvider\onError().

◆ onContentItem()

onContentItem ( )
protected

Process a valid content-item request.

Returns
bool True if no error

Definition at line 597 of file ToolProvider.php.

References ToolProvider\onError().

◆ onDashboard()

onDashboard ( )
protected

Process a valid dashboard request.

Returns
bool True if no error

Definition at line 587 of file ToolProvider.php.

References ToolProvider\onError().

◆ onError()

onError ( )
protected

Process a response to an invalid request.

Returns
bool True if no further error processing required

Definition at line 617 of file ToolProvider.php.

Referenced by ToolProvider\onConfigure(), ToolProvider\onContentItem(), ToolProvider\onDashboard(), ToolProvider\onLaunch(), and ToolProvider\onRegister().

◆ onLaunch()

onLaunch ( )
protected

Process a valid launch request.

Returns
bool True if no error

Definition at line 567 of file ToolProvider.php.

References ToolProvider\onError().

◆ onRegister()

onRegister ( )
protected

Process a valid tool proxy registration request.

Returns
bool True if no error

Definition at line 607 of file ToolProvider.php.

References ToolProvider\onError().

◆ parseRoles()

static parseRoles (   $roles,
  $ltiVersion = self::LTI_VERSION1 
)
static

Get an array of fully qualified user roles.

Parameters
mixed$rolesComma-separated list of roles or array of roles
string$ltiVersionLTI version (default is LTI-1p0)
Returns
array Array of roles

Definition at line 478 of file ToolProvider.php.

Referenced by Membership\get(), and ResourceLink\getMemberships().

◆ sendForm()

static sendForm (   $url,
  $params,
  $target = '' 
)
static

Generate a web page containing an auto-submitted form of parameters.

Parameters
string$urlURL to which the form should be submitted
array$paramsArray of form parameters
string$targetName of target (optional)
Returns
string

Definition at line 510 of file ToolProvider.php.

◆ setParameterConstraint()

setParameterConstraint (   $name,
  $required = true,
  $maxLength = null,
  $messageTypes = null 
)

Add a parameter constraint to be checked on launch.

Parameters
string$nameName of parameter to be checked
bool$requiredTrue if parameter is required (optional, default is true)
int$maxLengthMaximum permitted length of parameter value (optional, default is null)
array$messageTypesArray of message types to which the constraint applies (optional, default is all)

Definition at line 366 of file ToolProvider.php.

Field Documentation

◆ $allowSharing

bool $allowSharing = false

Whether shared resource link arrangements are permitted.

Definition at line 206 of file ToolProvider.php.

◆ $baseUrl

string null $baseUrl = null

Base URL for tool provider service.

Definition at line 234 of file ToolProvider.php.

◆ $consumer

ToolConsumer null $consumer = null

Tool Consumer object.

Definition at line 150 of file ToolProvider.php.

◆ $context

Context null $context = null

Context object.

Definition at line 178 of file ToolProvider.php.

◆ $dataConnector

DataConnector null $dataConnector = null

Data connector object.

Definition at line 185 of file ToolProvider.php.

Referenced by ToolProvider\__construct().

◆ $debugMode

bool $debugMode = false
protected

Whether debug messages explaining the cause of errors are to be returned to the tool consumer.

Definition at line 311 of file ToolProvider.php.

◆ $defaultEmail

string $defaultEmail = ''

Default email domain.

Definition at line 192 of file ToolProvider.php.

◆ $details

array $details = array()

Details for error message relating to last request processed.

Definition at line 227 of file ToolProvider.php.

◆ $documentTargets

array null $documentTargets = null
protected

Document targets accepted by the Tool Consumer.

Definition at line 290 of file ToolProvider.php.

◆ $errorOutput

string null $errorOutput = null
protected

HTML to be displayed on an unsuccessful completion of the request and no return URL is available.

Definition at line 304 of file ToolProvider.php.

◆ $idScope

int $idScope = self::ID_SCOPE_ID_ONLY

Scope to use for user IDs.

Definition at line 199 of file ToolProvider.php.

◆ $mediaTypes

array null $mediaTypes = null
protected

Media types accepted by the Tool Consumer.

Definition at line 283 of file ToolProvider.php.

◆ $message

string $message = self::CONNECTION_ERROR_MESSAGE

Message for last request processed.

Definition at line 213 of file ToolProvider.php.

◆ $messageParameters

array null $messageParameters = null
protected

LTI message parameters.

Definition at line 318 of file ToolProvider.php.

Referenced by ToolProvider\getMessageParameters().

◆ $ok

bool $ok = true

True if the last request was successful.

Definition at line 143 of file ToolProvider.php.

Referenced by ToolProvider\doToolProxyService().

◆ $optionalServices

array null $optionalServices = null

Optional services used by Tool Provider.

Definition at line 262 of file ToolProvider.php.

◆ $output

string null $output = null
protected

Default HTML to be displayed on a successful completion of the request.

Definition at line 297 of file ToolProvider.php.

◆ $product

Item null $product = null

Product details.

Definition at line 248 of file ToolProvider.php.

◆ $reason

string null $reason = null

Error message for last request processed.

Definition at line 220 of file ToolProvider.php.

◆ $redirectUrl

string null $redirectUrl = null
protected

URL to redirect user to on successful completion of the request.

Definition at line 276 of file ToolProvider.php.

◆ $requiredServices

array null $requiredServices = null

Services required by Tool Provider.

Definition at line 255 of file ToolProvider.php.

◆ $resourceHandlers

array null $resourceHandlers = null

Resource handlers for Tool Provider.

Definition at line 269 of file ToolProvider.php.

◆ $resourceLink

ResourceLink null $resourceLink = null

Resource link object.

Definition at line 171 of file ToolProvider.php.

◆ $returnUrl

string null $returnUrl = null

Return URL provided by tool consumer.

Definition at line 157 of file ToolProvider.php.

◆ $userResult

UserResult null $userResult = null

UserResult object.

Definition at line 164 of file ToolProvider.php.

◆ $vendor

Item null $vendor = null

Vendor details.

Definition at line 241 of file ToolProvider.php.

◆ CONNECTION_ERROR_MESSAGE

const CONNECTION_ERROR_MESSAGE = 'Sorry, there was an error connecting you to the application.'

Default connection error message.

Definition at line 26 of file ToolProvider.php.

◆ ID_SCOPE_CONTEXT

const ID_SCOPE_CONTEXT = 2

Prefix the ID with the consumer key and context ID.

Definition at line 51 of file ToolProvider.php.

Referenced by UserResult\getId().

◆ ID_SCOPE_GLOBAL

const ID_SCOPE_GLOBAL = 1

Prefix an ID with the consumer key.

Definition at line 46 of file ToolProvider.php.

Referenced by UserResult\getId().

◆ ID_SCOPE_ID_ONLY

◆ ID_SCOPE_RESOURCE

const ID_SCOPE_RESOURCE = 3

Prefix the ID with the consumer key and resource ID.

Definition at line 56 of file ToolProvider.php.

Referenced by Membership\get(), UserResult\getId(), and ResourceLink\getMemberships().

◆ ID_SCOPE_SEPARATOR

const ID_SCOPE_SEPARATOR = ':'

Character used to separate each element of an ID.

Definition at line 61 of file ToolProvider.php.

Referenced by UserResult\getId().

◆ LTI_VERSION1

const LTI_VERSION1 = 'LTI-1p0'

LTI version 1 for messages.

Definition at line 31 of file ToolProvider.php.

◆ LTI_VERSION2

const LTI_VERSION2 = 'LTI-2p0'

LTI version 2 for messages.

Definition at line 36 of file ToolProvider.php.


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