From 512a532650670fa38fd4ef79f124ce237e4474a7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 1 Mar 2009 19:11:01 +0000 Subject: Simplify the batch api by having the core event handlers for start_batch and end_batch add and remove the batch id from the session. Modules wishing to do batch processing, just need to fire the start_batch and end_batch events. Other modules that need to be aware of batches (i.e. notifications) just check the session for "batch_id". --- core/helpers/core_event.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/helpers') diff --git a/core/helpers/core_event.php b/core/helpers/core_event.php index e430319d..64cc9376 100644 --- a/core/helpers/core_event.php +++ b/core/helpers/core_event.php @@ -34,4 +34,16 @@ class core_event_Core { static function item_before_delete($item) { access::delete_item($item); } + + static function start_batch() { + $batch_id = Session::instance()->get("batch_id"); + if (empty($batch_id)) { + $batch_id = mt_rand(); + Session::instance()->set("batch_id", $batch_id); + } + } + + static function end_batch() { + Session::instance()->delete("batch_id"); + } } -- cgit v1.2.3