diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-01 19:11:01 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-01 19:11:01 +0000 |
commit | 512a532650670fa38fd4ef79f124ce237e4474a7 (patch) | |
tree | c5230dce813e9f96ff127de5dbb535b2ef046cef /core/helpers | |
parent | bed1bb48f33c1c20decb6b592b1d713f5c9fb48e (diff) |
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".
Diffstat (limited to 'core/helpers')
-rw-r--r-- | core/helpers/core_event.php | 12 |
1 files changed, 12 insertions, 0 deletions
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"); + } } |