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

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

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...
 

Static Public Member Functions

static parseRoles ($roles)
 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...
 

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...
 
 $user = null
 User 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...
 
 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
 URL to redirect user to on successful completion of the request. More...
 
 $documentTargets = null
 URL to redirect user to on successful completion of the request. More...
 
 $output = null
 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...
 

Detailed Description

Class to represent an LTI Tool Provider.

Author
Stephen P Vickers svick.nosp@m.ers@.nosp@m.imsgl.nosp@m.obal.nosp@m..org
Date
2016
Version
3.0.2
Licence:
GNU Lesser General Public License, version 3 (http://www.gnu.org/licenses/lgpl.html)

Definition at line 21 of file ToolProvider.php.

Constructor & Destructor Documentation

__construct (   $dataConnector)

Class constructor.

Parameters
DataConnector$dataConnectorObject containing a database connection object

Definition at line 311 of file ToolProvider.php.

References ToolProvider\$dataConnector.

Member Function Documentation

doToolProxyService ( )

Send the tool proxy to the Tool Consumer.

Returns
boolean True if the tool proxy was accepted

Definition at line 423 of file ToolProvider.php.

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

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

Referenced by ToolProvider\doToolProxyService(), and ToolProvider\onError().

getConsumers ( )

Get an array of defined tool consumers.

Returns
array Array of ToolConsumer objects

Definition at line 373 of file ToolProvider.php.

handleRequest ( )

Process an incoming request.

Definition at line 338 of file ToolProvider.php.

onContentItem ( )
protected

Process a valid content-item request.

Returns
boolean True if no error

Definition at line 542 of file ToolProvider.php.

References ToolProvider\onError().

onLaunch ( )
protected

Process a valid launch request.

Returns
boolean True if no error

Definition at line 530 of file ToolProvider.php.

References ToolProvider\onError().

onRegister ( )
protected

Process a valid tool proxy registration request.

Returns
boolean True if no error

Definition at line 554 of file ToolProvider.php.

References ToolProvider\onError().

static parseRoles (   $roles)
static

Get an array of fully qualified user roles.

Parameters
mixed$rolesComma-separated list of roles or array of roles
Returns
array Array of roles

Definition at line 450 of file ToolProvider.php.

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

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

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
boolean$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 358 of file ToolProvider.php.

Field Documentation

boolean $allowSharing = false

Whether shared resource link arrangements are permitted.

Definition at line 200 of file ToolProvider.php.

string $baseUrl = null

Base URL for tool provider service.

Definition at line 224 of file ToolProvider.php.

ToolConsumer $consumer = null

Tool Consumer object.

Definition at line 152 of file ToolProvider.php.

Referenced by ToolProvider\onError().

Context $context = null

Context object.

Definition at line 176 of file ToolProvider.php.

DataConnector $dataConnector = null

Data connector object.

Definition at line 182 of file ToolProvider.php.

Referenced by ToolProvider\__construct().

boolean $debugMode = false
protected

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

Definition at line 291 of file ToolProvider.php.

string $defaultEmail = ''

Default email domain.

Definition at line 188 of file ToolProvider.php.

Referenced by ToolProvider\onError().

array $details = array()

Details for error message relating to last request processed.

Definition at line 218 of file ToolProvider.php.

string $documentTargets = null
protected

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

Definition at line 273 of file ToolProvider.php.

Referenced by ToolProvider\onError().

string $errorOutput = null
protected

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

Definition at line 285 of file ToolProvider.php.

Referenced by ToolProvider\onError().

int $idScope = self::ID_SCOPE_ID_ONLY

Scope to use for user IDs.

Definition at line 194 of file ToolProvider.php.

string $mediaTypes = null
protected

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

Definition at line 267 of file ToolProvider.php.

Referenced by ToolProvider\onError().

string $message = self::CONNECTION_ERROR_MESSAGE

Message for last request processed.

Definition at line 206 of file ToolProvider.php.

Referenced by ToolProvider\onError().

boolean $ok = true

True if the last request was successful.

Definition at line 146 of file ToolProvider.php.

Referenced by ToolProvider\doToolProxyService(), and ToolProvider\onError().

array $optionalServices = null

Optional services used by Tool Provider.

Definition at line 248 of file ToolProvider.php.

string $output = null
protected

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

Definition at line 279 of file ToolProvider.php.

Referenced by ToolProvider\onError().

Item $product = null

Product details.

Definition at line 236 of file ToolProvider.php.

string $reason = null

Error message for last request processed.

Definition at line 212 of file ToolProvider.php.

Referenced by ToolProvider\onError().

string $redirectUrl = null
protected

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

Definition at line 261 of file ToolProvider.php.

array $requiredServices = null

Services required by Tool Provider.

Definition at line 242 of file ToolProvider.php.

array $resourceHandlers = null

Resource handlers for Tool Provider.

Definition at line 254 of file ToolProvider.php.

ResourceLink $resourceLink = null

Resource link object.

Definition at line 170 of file ToolProvider.php.

Referenced by ToolProvider\onError().

string $returnUrl = null

Return URL provided by tool consumer.

Definition at line 158 of file ToolProvider.php.

Referenced by ToolProvider\onError().

User $user = null

User object.

Definition at line 164 of file ToolProvider.php.

Item $vendor = null

Vendor details.

Definition at line 230 of file ToolProvider.php.

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

Default connection error message.

Definition at line 27 of file ToolProvider.php.

const ID_SCOPE_CONTEXT = 2

Prefix the ID with the consumer key and context ID.

Definition at line 48 of file ToolProvider.php.

Referenced by User\getId().

const ID_SCOPE_GLOBAL = 1

Prefix an ID with the consumer key.

Definition at line 44 of file ToolProvider.php.

Referenced by User\getId().

const ID_SCOPE_RESOURCE = 3

Prefix the ID with the consumer key and resource ID.

Definition at line 52 of file ToolProvider.php.

Referenced by ResourceLink\doMembershipsService(), Membership\get(), and User\getId().

const ID_SCOPE_SEPARATOR = ':'

Character used to separate each element of an ID.

Definition at line 56 of file ToolProvider.php.

Referenced by User\getId().

const LTI_VERSION1 = 'LTI-1p0'

LTI version 1 for messages.

Definition at line 32 of file ToolProvider.php.

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: