public function LtiToolProviderProvisionEventSubscriber::onCreateProvision in LTI Tool Provider 8
Same name and namespace in other branches
- 2.x 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 95
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.');
}
}