From 8abb5b020f5061aa108e5757ac263c6778580c4e Mon Sep 17 00:00:00 2001 From: Saophalkun Ponlu Date: Tue, 28 Oct 2008 03:24:06 +0000 Subject: [PATCH] API CHANGE: Added LastChange() method to BulkLoader_Result git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64807 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/BulkLoader.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/dev/BulkLoader.php b/dev/BulkLoader.php index 1a8469c41..1cf380a10 100644 --- a/dev/BulkLoader.php +++ b/dev/BulkLoader.php @@ -261,6 +261,13 @@ class BulkLoader_Result extends Object { * @var array (see {@link $created}) */ protected $deleted = array(); + + /** + * Stores the last change. + * It is in the same format as {@link $created} but with an additional key, "ChangeType", which will be set to + * one of 3 strings: "created", "updated", or "deleted" + */ + protected $lastChange = array(); /** * Returns the count of all objects which were @@ -317,16 +324,26 @@ class BulkLoader_Result extends Object { return $this->mapToDataObjectSet($this->deleted); } + /** + * Returns the last change. + * It is in the same format as {@link $created} but with an additional key, "ChangeType", which will be set to + * one of 3 strings: "created", "updated", or "deleted" + */ + public function LastChange() { + return $this->lastChange; + } + /** * @param $obj DataObject * @param $message string */ public function addCreated($obj, $message = null) { - $this->created[] = array( + $this->created[] = $this->lastChange = array( 'ID' => $obj->ID, 'ClassName' => $obj->class, 'Message' => $message ); + $this->lastChange['ChangeType'] = 'created'; } /** @@ -334,11 +351,12 @@ class BulkLoader_Result extends Object { * @param $message string */ public function addUpdated($obj, $message = null) { - $this->updated[] = array( + $this->updated[] = $this->lastChange = array( 'ID' => $obj->ID, 'ClassName' => $obj->class, 'Message' => $message ); + $this->lastChange['ChangeType'] = 'updated'; } /** @@ -346,11 +364,12 @@ class BulkLoader_Result extends Object { * @param $message string */ public function addDeleted($obj, $message = null) { - $this->deleted[] = array( + $this->deleted[] = $this->lastChange = array( 'ID' => $obj->ID, 'ClassName' => $obj->class, 'Message' => $message ); + $this->lastChange['ChangeType'] = 'deleted'; } /**