You are here

public function LtiToolProviderEvent::sendLtiError in LTI Tool Provider 2.x

Same name and namespace in other branches
  1. 8 src/LtiToolProviderEvent.php \Drupal\lti_tool_provider\LtiToolProviderEvent::sendLtiError()

Send an error back to the LMS.

Parameters

array $context: The LTI context.

string $message: The error message to send.

File

src/LtiToolProviderEvent.php, line 70

Class

LtiToolProviderEvent

Namespace

Drupal\lti_tool_provider

Code

public function sendLtiError(array $context, string $message) {
  if (isset($context['launch_presentation_return_url']) && !empty($context['launch_presentation_return_url'])) {
    $url = Url::fromUri($context['launch_presentation_return_url'])
      ->setOption('query', [
      'lti_errormsg' => $message,
    ])
      ->setAbsolute(TRUE)
      ->toString();
    $response = new RedirectResponse($url);
    $response
      ->send();
  }
}