public function ProvisionService::syncProvisionedEntity 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::syncProvisionedEntity()
Parameters
array $context:
EntityInterface $entity:
Return value
Throws
Exception
1 call to ProvisionService::syncProvisionedEntity()
- ProvisionService::provision in modules/
lti_tool_provider_provision/ src/ Services/ ProvisionService.php
File
- modules/
lti_tool_provider_provision/ src/ Services/ ProvisionService.php, line 151
Class
Namespace
Drupal\lti_tool_provider_provision\ServicesCode
public function syncProvisionedEntity(array $context, EntityInterface $entity) : EntityInterface {
$entityDefaults = $this->config
->get('entity_defaults');
if ($entityDefaults) {
foreach ($entityDefaults as $name => $entityDefault) {
if ($entity instanceof ContentEntityBase && isset($context[$entityDefault]) && !empty($context[$entityDefault])) {
$entity
->set($name, $context[$entityDefault]);
}
}
}
$event = new LtiToolProviderProvisionSyncProvisionedEntityEvent($context, $entity);
LtiToolProviderEvent::dispatchEvent($this->eventDispatcher, $event);
if ($event
->isCancelled()) {
throw new Exception($event
->getMessage());
}
$entity = $event
->getEntity();
return $entity;
}