Skip to content

Commit

Permalink
Merge pull request #45 from mattwright/deep-link-settings-data
Browse files Browse the repository at this point in the history
Fix a PHP warning when optional 'data' property of deep link settings is not present in message launch.
  • Loading branch information
dbhynds authored Jan 18, 2022
2 parents 0edb00f + b516b46 commit 527563b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/LtiDeepLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ public function getResponseJwt($resources)
LtiConstants::MESSAGE_TYPE => 'LtiDeepLinkingResponse',
LtiConstants::VERSION => LtiConstants::V1_3,
LtiConstants::DL_CONTENT_ITEMS => array_map(function ($resource) { return $resource->toArray(); }, $resources),
LtiConstants::DL_DATA => $this->deep_link_settings['data'],
];

// https://www.imsglobal.org/spec/lti-dl/v2p0/#deep-linking-request-message
// 'data' is an optional property which, if it exists, must be returned by the tool
if (isset($this->deep_link_settings['data'])) {
$message_jwt[LtiConstants::DL_DATA] = $this->deep_link_settings['data'];
}

return JWT::encode($message_jwt, $this->registration->getToolPrivateKey(), 'RS256', $this->registration->getKid());
}

Expand Down

0 comments on commit 527563b

Please sign in to comment.