public function ProvisionService::createProvisionedEntity in LTI Tool Provider 2.x
Same name and namespace in other branches
- 8 modules/lti_tool_provider_provision/src/Services/ProvisionService.php \Drupal\lti_tool_provider_provision\Services\ProvisionService::createProvisionedEntity()
Parameters
array $context:
EntityInterface|LtiToolProviderProvision $provision:
Return value
Throws
InvalidPluginDefinitionException
Exception
1 call to ProvisionService::createProvisionedEntity()
- ProvisionService::provision in modules/
lti_tool_provider_provision/ src/ Services/ ProvisionService.php
File
- modules/
lti_tool_provider_provision/ src/ Services/ ProvisionService.php, line 152
Class
Namespace
Drupal\lti_tool_provider_provision\ServicesCode
public function createProvisionedEntity(array $context, EntityInterface $provision) : EntityInterface {
$entityType = $provision
->get('provision_type')->value;
$entityBundle = $provision
->get('provision_bundle')->value;
$bundleType = $this->entityTypeManager
->getDefinition($entityType)
->getKey('bundle');
$entity = $this->entityTypeManager
->getStorage($entityType)
->create([
$bundleType => $entityBundle,
]);
$event = new LtiToolProviderProvisionCreateProvisionedEntityEvent($context, $entity);
LtiToolProviderEvent::dispatchEvent($this->eventDispatcher, $event);
if ($event
->isCancelled()) {
throw new Exception($event
->getMessage());
}
$entity = $event
->getEntity();
return $entity;
}