ILIAS  release_8 Revision v8.24
PersistingObserver.php
Go to the documentation of this file.
1<?php
2
20
25
32{
33 protected \ILIAS\BackgroundTasks\Bucket $bucket;
34 protected \ILIAS\BackgroundTasks\Persistence $persistence;
35
37 {
38 $this->bucket = $bucket;
39 $this->persistence = $persistence;
40 }
41
45 public function notifyState(int $state): void
46 {
47 $this->bucket->setState($state);
48 $this->bucket->heartbeat();
49 $this->persistence->updateBucket($this->bucket);
50 }
51
52 public function notifyPercentage(Task $task, int $percentage): void
53 {
54 $this->bucket->setPercentage($task, $percentage);
55 $this->bucket->heartbeat();
56 $this->persistence->updateBucket($this->bucket);
57 }
58
59 public function notifyCurrentTask(Task $task): void
60 {
61 $this->bucket->setCurrentTask($task);
62 $this->bucket->heartbeat();
63 $this->persistence->updateBucket($this->bucket);
64 }
65
70 public function heartbeat(): void
71 {
72 $this->bucket->heartbeat();
73 $this->persistence->updateBucket($this->bucket);
74 }
75}
heartbeat()
I'm still alive! If your calculation takes a really long time don't forget to use the heartbeat.
notifyCurrentTask(Task $task)
If the current task changes notify the observer.
notifyPercentage(Task $task, int $percentage)
You can change the progress of a currently running task.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Job.php:19