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)
|
||||
{
|
||||
$previousDetectLE = ini_get('auto_detect_line_endings');
|
||||
|
||||
ini_set('auto_detect_line_endings', true);
|
||||
|
||||
$this->extend('onBeforeProcessAll', $filepath, $preview);
|
||||
|
||||
$result = BulkLoader_Result::create();
|
||||
|
||||
try {
|
||||
@ -145,6 +147,9 @@ class CsvBulkLoader extends BulkLoader
|
||||
} finally {
|
||||
ini_set('auto_detect_line_endings', $previousDetectLE);
|
||||
}
|
||||
|
||||
$this->extend('onAfterProcessAll', $result, $preview);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -382,6 +387,8 @@ class CsvBulkLoader extends BulkLoader
|
||||
}
|
||||
}
|
||||
|
||||
$isChanged = $obj->isChanged();
|
||||
|
||||
// write record
|
||||
if (!$preview) {
|
||||
$obj->write();
|
||||
@ -392,11 +399,15 @@ class CsvBulkLoader extends BulkLoader
|
||||
|
||||
// save to results
|
||||
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);
|
||||
} else {
|
||||
$results->addCreated($obj, $message);
|
||||
}
|
||||
|
||||
$this->extend('onAfterProcessRecord', $obj, $preview, $isChanged);
|
||||
|
||||
$objID = $obj->ID;
|
||||
|
||||
$obj->destroy();
|
||||
|
Loading…
Reference in New Issue
Block a user