ToolDeploymentService
in package
One LTI deployment of an outbound registration, and where it may be used.
The deployment row is the LTI deployment_id. It is not owned by one org or one course. Scope is many-to-many: lti_tool_deployment_org and lti_tool_deployment_context. Assigning an organization makes the deployment available to courses in that organization and below it. That lookup is one statement. The ancestor walk is a recursive CTE inside the same query.
A deployment with no scope rows is not visible. Blank does not mean the whole tenant. key_id stays on the deployment and on every assignment so a scope cannot leave the tenant.
LTI 1.3 may have many deployments, each with its own external deployment_id. LTI 1.1 has exactly one deployment and that deployment_id is null. The row exists so scope lookup is the same for both protocols. The unique key on (registration_id, deployment_id) does not enforce that, because MySQL allows many null deployment ids. createDeployment() does.
Table of Contents
Methods
- assignContext() : void
- assignOrg() : void
- createDeployment() : int
- ensureLti11Deployments() : int
- Give each LTI 1.1 registration the one deployment it is missing.
- getDeploymentsForContext() : array<int, array<string, mixed>>
- Deployment rows available to a course: an explicit course assignment, or an assignment to the course's organization or one of its ancestors.
- getRegistrationsForContext() : array<int, array<string, mixed>>
- Registrations visible to a course. The same registration is returned once even when more than one of its deployments apply.
- onlyDeploymentId() : int
- The single deployment on a registration.
- resolveLti11() : array{registration_id: int, key_id: int, lti11_key: string, tool_deployment_id: int, deployment_id: null}
- The registration and its one deployment for an LTI 1.1 key and secret.
- db() : PDOX
- deploymentCount() : int
- findContext() : array<string, mixed>|null
- findOrg() : array<string, mixed>|null
- insertScope() : void
- lockRegistration() : void
- optionalDeploymentId() : string|null
- prefix() : string
- requireDeployment() : array<string, mixed>
- requireId() : int
- requireRegistration() : array<string, mixed>
- rowsForContext() : array<int, array<string, mixed>>
Methods
assignContext()
public
static assignContext(int $toolDeploymentId, int $contextId) : void
Parameters
- $toolDeploymentId : int
- $contextId : int
assignOrg()
public
static assignOrg(int $toolDeploymentId, int $orgId) : void
Parameters
- $toolDeploymentId : int
- $orgId : int
createDeployment()
public
static createDeployment(int $registrationId[, string|null $deploymentId = null ]) : int
Parameters
- $registrationId : int
- $deploymentId : string|null = null
-
external LTI deployment_id
Return values
int —tool_deployment_id
ensureLti11Deployments()
Give each LTI 1.1 registration the one deployment it is missing.
public
static ensureLti11Deployments() : int
Does not change consumer keys, secrets, launch URLs, or an existing deployment_id. A registration that already has a deployment is left alone, including one that already has its single null deployment. Calling this again inserts nothing.
Return values
int —number of deployment rows inserted
getDeploymentsForContext()
Deployment rows available to a course: an explicit course assignment, or an assignment to the course's organization or one of its ancestors.
public
static getDeploymentsForContext(int $contextId) : array<int, array<string, mixed>>
Parameters
- $contextId : int
Return values
array<int, array<string, mixed>>getRegistrationsForContext()
Registrations visible to a course. The same registration is returned once even when more than one of its deployments apply.
public
static getRegistrationsForContext(int $contextId) : array<int, array<string, mixed>>
Parameters
- $contextId : int
Return values
array<int, array<string, mixed>>onlyDeploymentId()
The single deployment on a registration.
public
static onlyDeploymentId(int $registrationId) : int
An LTI 1.1 registration has exactly one. Callers that just created that registration use this to assign the course and its grants.
Parameters
- $registrationId : int
Return values
int —tool_deployment_id
resolveLti11()
The registration and its one deployment for an LTI 1.1 key and secret.
public
static resolveLti11(string $consumerKey, string $sharedSecret, int $keyId) : array{registration_id: int, key_id: int, lti11_key: string, tool_deployment_id: int, deployment_id: null}
lti11_key is a stored field, not an identifier. Several registrations in one tenant may share it. The secret picks among those rows. A wrong secret, an unknown key, or more than one row with that key and secret is the same result.
Parameters
- $consumerKey : string
- $sharedSecret : string
- $keyId : int
-
tenant key
Return values
array{registration_id: int, key_id: int, lti11_key: string, tool_deployment_id: int, deployment_id: null}db()
private
static db() : PDOX
Return values
PDOXdeploymentCount()
private
static deploymentCount(int $registrationId) : int
Parameters
- $registrationId : int
Return values
intfindContext()
private
static findContext(int $contextId) : array<string, mixed>|null
Parameters
- $contextId : int
Return values
array<string, mixed>|nullfindOrg()
private
static findOrg(int $orgId) : array<string, mixed>|null
Parameters
- $orgId : int
Return values
array<string, mixed>|nullinsertScope()
private
static insertScope(string $table, string $targetColumn, int $toolDeploymentId, int $targetId, int $keyId, string $duplicate) : void
Parameters
- $table : string
-
unprefixed table name
- $targetColumn : string
-
org_id or context_id
- $toolDeploymentId : int
- $targetId : int
- $keyId : int
-
copied from the deployment, not from the caller
- $duplicate : string
lockRegistration()
private
static lockRegistration(int $registrationId) : void
Parameters
- $registrationId : int
optionalDeploymentId()
private
static optionalDeploymentId(mixed $deploymentId) : string|null
Parameters
- $deploymentId : mixed
Return values
string|nullprefix()
private
static prefix() : string
Return values
stringrequireDeployment()
private
static requireDeployment(int $toolDeploymentId) : array<string, mixed>
Parameters
- $toolDeploymentId : int
Return values
array<string, mixed>requireId()
private
static requireId(mixed $id, string $label) : int
Parameters
- $id : mixed
- $label : string
Return values
intrequireRegistration()
private
static requireRegistration(int $registrationId) : array<string, mixed>
Parameters
- $registrationId : int
Return values
array<string, mixed>rowsForContext()
private
static rowsForContext(int $contextId, bool $registrations) : array<int, array<string, mixed>>
Parameters
- $contextId : int
- $registrations : bool