public static function NodeExport::export in Node export 8
Exports nodes to a specified format to a file/code.
Parameters
int[] $ids: The ids of the nodes to be exported.
string $format: The format of the file to be saved.
bool $save: Whether to save the file or return the code.
Return value
\Drupal\file\FileInterface|false|string Returns either the code to be exported, file entity or FALSE.
5 calls to NodeExport::export()
- BulkNodeExport::buildForm in src/
Form/ BulkNodeExport.php - Form constructor.
- drush_node_export_export in ./
node_export.drush.inc - Drush command logic for command node_export_export.
- NodeExport::nodeExportFinishedCallback in src/
NodeExport.php - Batch finish callback method. Handles results & display messages to user.
- NodeExportCommands::exportNode in src/
Commands/ NodeExportCommands.php - Export nodes.
- NodeExportForm::buildForm in src/
Form/ NodeExportForm.php - Form constructor.
File
- src/
NodeExport.php, line 61
Class
- NodeExport
- Provides a Node Export function.
Namespace
Drupal\node_exportCode
public static function export(array $ids, $format, $save) {
$nodesArray = NodeExport::getNodesArray($ids);
switch ($format) {
case 'dsv':
// TODO: Implement delimiter separated values.
break;
case 'json':
$data = json_encode($nodesArray);
break;
case 'serialize':
// TODO: Implement PHP serialized object.
break;
case 'xml':
// TODO: Implement XML.
break;
}
return $save ? file_save_data($data, NodeExport::getFileUri($format), FileSystemInterface::EXISTS_REPLACE) : $data;
}