public function ExportEntityWriter::write in Content Synchronizer 8
Same name and namespace in other branches
- 8.2 src/Processors/ExportEntityWriter.php \Drupal\content_synchronizer\Processors\ExportEntityWriter::write()
- 3.x src/Processors/ExportEntityWriter.php \Drupal\content_synchronizer\Processors\ExportEntityWriter::write()
Write the document to export.
Parameters
\Drupal\Core\Entity\Entity $entityToExport: The entity to export.
array $dataToExport: The data to export.
File
- src/
Processors/ ExportEntityWriter.php, line 64
Class
- ExportEntityWriter
- Export entity writer.
Namespace
Drupal\content_synchronizer\ProcessorsCode
public function write(Entity $entityToExport, array $dataToExport) {
if (array_key_exists('gid', $dataToExport) && ($gid = $dataToExport['gid'])) {
// Get the previous exported entities :
if ($allExportedData = $this
->getExportedData($entityToExport)) {
// If the current entity has already been exported, the writer don't do anything.
if (array_key_exists($gid, $allExportedData)) {
return;
}
}
else {
$allExportedData = [];
}
// Add the current entity to export to the already exported data.
$allExportedData[$gid] = $dataToExport;
// Write files :
$this
->writeJson($allExportedData, $this
->getExpotedDataTypeFilePath($entityToExport));
}
}