mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Extension hooks for CsvBulkLoader
Required for versioned-snapshots integration
This commit is contained in:
parent
ad4e488dcf
commit
8c0efd3980
@ -69,8 +69,10 @@ class CsvBulkLoader extends BulkLoader
|
|||||||
protected function processAll($filepath, $preview = false)
|
protected function processAll($filepath, $preview = false)
|
||||||
{
|
{
|
||||||
$previousDetectLE = ini_get('auto_detect_line_endings');
|
$previousDetectLE = ini_get('auto_detect_line_endings');
|
||||||
|
|
||||||
ini_set('auto_detect_line_endings', true);
|
ini_set('auto_detect_line_endings', true);
|
||||||
|
|
||||||
|
$this->extend('onBeforeProcessAll', $filepath, $preview);
|
||||||
|
|
||||||
$result = BulkLoader_Result::create();
|
$result = BulkLoader_Result::create();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -145,6 +147,9 @@ class CsvBulkLoader extends BulkLoader
|
|||||||
} finally {
|
} finally {
|
||||||
ini_set('auto_detect_line_endings', $previousDetectLE);
|
ini_set('auto_detect_line_endings', $previousDetectLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->extend('onAfterProcessAll', $result, $preview);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,6 +387,8 @@ class CsvBulkLoader extends BulkLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isChanged = $obj->isChanged();
|
||||||
|
|
||||||
// write record
|
// write record
|
||||||
if (!$preview) {
|
if (!$preview) {
|
||||||
$obj->write();
|
$obj->write();
|
||||||
@ -392,11 +399,15 @@ class CsvBulkLoader extends BulkLoader
|
|||||||
|
|
||||||
// save to results
|
// save to results
|
||||||
if ($existingObj) {
|
if ($existingObj) {
|
||||||
|
// We mark as updated regardless of isChanged, since custom formatters and importers
|
||||||
|
// might have affected relationships and other records.
|
||||||
$results->addUpdated($obj, $message);
|
$results->addUpdated($obj, $message);
|
||||||
} else {
|
} else {
|
||||||
$results->addCreated($obj, $message);
|
$results->addCreated($obj, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->extend('onAfterProcessRecord', $obj, $preview, $isChanged);
|
||||||
|
|
||||||
$objID = $obj->ID;
|
$objID = $obj->ID;
|
||||||
|
|
||||||
$obj->destroy();
|
$obj->destroy();
|
||||||
|
Loading…
Reference in New Issue
Block a user