private function Exporter::editEntityData in Default Content Deploy 8
Remove or add a new fields to serialize entities data.
1 call to Exporter::editEntityData()
- Exporter::export in src/
Exporter.php - Export entities by entity type, id or bundle.
File
- src/
Exporter.php, line 475
Class
- Exporter
- A service for handling export of default content.
Namespace
Drupal\default_content_deployCode
private function editEntityData() {
foreach ($this->exportedEntities as $entity_type => $uuids) {
foreach ($uuids as $uuid => $serialisation_entity) {
$entity_array = $this->serializer
->decode($serialisation_entity, 'hal_json');
$entity_type_object = $this->entityTypeManager
->getDefinition($entity_type);
$id_key = $entity_type_object
->getKey('id');
$entity_id = $entity_array[$id_key][0]['value'];
$entity = $this->entityTypeManager
->getStorage($entity_type)
->load($entity_id);
// Removed data.
unset($entity_array[$entity_type_object
->getKey('revision')]);
// Add data.
if ($entity_type === 'user') {
$entity_array['pass'][0]['value'] = $entity
->getPassword();
}
$data = $this->serializer
->serialize($entity_array, 'hal_json', [
'json_encode_options' => JSON_PRETTY_PRINT,
]);
$this->exportedEntities[$entity_type][$uuid] = $data;
}
}
}