public function ContentSynchronizerManager::exportEntity in Content Synchronizer 3.x
Export a single entity.
Parameters
string $entityTypeId: The entity type id.
int $id: The entity id.
string $destination: The entity id.
Return value
array The destination data.
File
- src/
Service/ ContentSynchronizerManager.php, line 188
Class
- ContentSynchronizerManager
- ContentSynchronizerManager service.
Namespace
Drupal\content_synchronizer\ServiceCode
public function exportEntity($entityTypeId, $id, $destination = '') {
/** @var \Drupal\Core\Entity\EntityStorageInterface $entityTypeManager */
$entityTypeManager = $this->entityTypeManager
->getStorage($entityTypeId);
if (!$entityTypeManager) {
throw new \Exception('No entity type "' . $entityTypeId . '" found');
}
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = $entityTypeManager
->load($id);
if (!$entity) {
throw new \Exception('No entity found [type:' . $entityTypeId . ', id:' . $id . ']');
}
return $this
->createExportFile([
$entity,
], NULL, $destination);
}