public function LtiToolProviderProvisionEventSubscriber::onLaunch in LTI Tool Provider 2.x
Same name and namespace in other branches
- 8 modules/lti_tool_provider_provision/src/EventSubscriber/LtiToolProviderProvisionEventSubscriber.php \Drupal\lti_tool_provider_provision\EventSubscriber\LtiToolProviderProvisionEventSubscriber::onLaunch()
Parameters
LtiToolProviderLaunchRedirectEvent $event:
File
- modules/
lti_tool_provider_provision/ src/ EventSubscriber/ LtiToolProviderProvisionEventSubscriber.php, line 63
Class
Namespace
Drupal\lti_tool_provider_provision\EventSubscriberCode
public function onLaunch(LtiToolProviderLaunchRedirectEvent $event) {
$context = $event
->getContext();
try {
if ($entity = $this->provisionService
->provision($context)) {
if ($this->configFactory
->get('lti_tool_provider_provision.settings')
->get('entity_sync')) {
$this->provisionService
->syncProvisionedEntity($context, $entity);
$entity
->save();
}
$provisionEvent = new LtiToolProviderProvisionEvent($context, $entity, $entity
->toUrl()
->toString());
LtiToolProviderEvent::dispatchEvent($this->eventDispatcher, $provisionEvent);
if ($provisionEvent
->isCancelled()) {
throw new Exception($event
->getMessage());
}
if ($this->configFactory
->get('lti_tool_provider_provision.settings')
->get('entity_redirect')) {
$event
->setDestination($provisionEvent
->getDestination());
}
}
} catch (Exception $e) {
$event
->sendLtiError($context, $e
->getMessage());
Drupal::logger('lti_tool_provider_provision')
->error($e
->getMessage());
}
}