function drush_node_export_import in Node export 8
Drush 8 command to import nodes.
1 string reference to 'drush_node_export_import'
- node_export_drush_command in ./
node_export.drush.inc - Implements hook_drush_command().
File
- ./
node_export.drush.inc, line 109 - Drush integration for Node Export module.
Code
function drush_node_export_import() {
$file = drush_get_arguments()[1];
$data = file_get_contents($file);
if ($data) {
$nodes = json_decode($data, TRUE);
$countImported = 0;
$countNotImported = 0;
foreach ($nodes as $node) {
$id = NodeImport::import($node);
$id ? $countImported++ : $countNotImported++;
}
if ($countImported > 0) {
drush_print(dt('@count nodes imported successfully.', [
'@count' => $countImported,
]));
}
if ($countNotImported > 0) {
drush_set_error(dt('@count nodes could not be imported.', [
'@count' => $countNotImported,
]));
}
}
else {
drush_set_error('Could not read the file.');
}
}