public function ProvisionService::createProvisionedEntity in LTI Tool Provider 8
Same name and namespace in other branches
- 2.x 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 125
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;
}