protected function ConfigEntityHandler::getEntityWithValues in Acquia Content Hub 8.2
Gets the proper configuration entity with the new values.
This will load an existing entity from the local environment if one by the same id exists. Otherwise it will generate a new entity of the right type. In either case, it will populate that entity with the appropriate values.
Parameters
string $entity_type_id: The entity type we are creating.
array $default_values: The values to set for that entity.
Return value
\Drupal\Core\Config\Entity\ConfigEntityInterface The configuration entity with its appropriate values.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to ConfigEntityHandler::getEntityWithValues()
- ConfigEntityHandler::onParseCdf in src/
EventSubscriber/ Cdf/ ConfigEntityHandler.php - Parses the CDF representation of Configuration Entities.
File
- src/
EventSubscriber/ Cdf/ ConfigEntityHandler.php, line 181
Class
- ConfigEntityHandler
- The Configuration entity CDF creator.
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfCode
protected function getEntityWithValues(string $entity_type_id, array $default_values) : ConfigEntityInterface {
$entity = \Drupal::entityTypeManager()
->getStorage($entity_type_id)
->createFromStorageRecord($default_values);
if ($old_entity = \Drupal::entityTypeManager()
->getStorage($entity_type_id)
->load($entity
->id())) {
// @todo check if this entity was previously imported. (Multiple entities of the same ID from different publishers)
$default_values['uuid'] = $old_entity
->uuid();
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $old_entity */
$old_entity = \Drupal::entityTypeManager()
->getStorage($entity_type_id)
->createFromStorageRecord($default_values);
$old_entity
->enforceIsNew(FALSE);
return $old_entity;
}
return $entity;
}