X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FBackgroundJob.pm;h=3ab5125228e87d93a00981023660e01f7e70d0fa;hb=5d6c092921919526ade501facb1220f8a108a08f;hp=6830565ce4114fa7dacfef218f8c589599877318;hpb=642779f217785d594b5d11d0ecbef56d21b562bd;p=koha_fer diff --git a/C4/BackgroundJob.pm b/C4/BackgroundJob.pm index 6830565ce4..3ab5125228 100644 --- a/C4/BackgroundJob.pm +++ b/C4/BackgroundJob.pm @@ -83,6 +83,7 @@ sub new { $self->{'progress'} = 0; $self->{'status'} = "running"; $self->{'jobID'} = Digest::MD5::md5_hex(Digest::MD5::md5_hex(time().{}.rand().{}.$$)); + $self->{'extra_values'} = {}; bless $self, $class; $self->_serialize(); @@ -260,6 +261,45 @@ sub fetch { return $self; } +=head2 set + +=over 4 + +=item $job->set($hashref); + +=back + +Set some variables into the hashref. +These variables can be retrieved using the get method. + +=cut + +sub set { + my ($self, $hashref) = @_; + while ( my ($k, $v) = each %$hashref ) { + $self->{extra_values}->{$k} = $v; + } + $self->_serialize(); + return; +} + +=head2 get + +=over 4 + +=item $value = $job->get($key); + +=back + +Get a variable which has been previously stored with the set method. + +=cut + +sub get { + my ($self, $key) = @_; + return $self->{extra_values}->{$key}; +} + 1; __END__