public function LtiToolProviderProvisionEventSubscriber::onCreateProvision 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::onCreateProvision()
Parameters
LtiToolProviderProvisionCreateProvisionEvent $event:
File
- modules/
lti_tool_provider_provision/ src/ EventSubscriber/ LtiToolProviderProvisionEventSubscriber.php, line 96
Class
Namespace
Drupal\lti_tool_provider_provision\EventSubscriberCode
public function onCreateProvision(LtiToolProviderProvisionCreateProvisionEvent $event) {
$context = $event
->getContext();
$access = TRUE;
if ($this->configFactory
->get('lti_tool_provider_provision.settings')
->get('allowed_roles_enabled')) {
$access = FALSE;
$ltiRoles = parse_roles($context['roles']);
$allowedRoles = $this->configFactory
->get('lti_tool_provider_provision.settings')
->get('allowed_roles');
foreach ($ltiRoles as $ltiRole) {
if (isset($allowedRoles[$ltiRole]) && $allowedRoles[$ltiRole]) {
$access = TRUE;
break;
}
}
}
if (!$access) {
$event
->cancel('Unable to provision entity.');
}
}