ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
PersistingObserver.php
Go to the documentation of this file.
1 <?php
2 
20 
25 
31 class PersistingObserver implements Observer
32 {
33  protected \ILIAS\BackgroundTasks\Bucket $bucket;
34  protected \ILIAS\BackgroundTasks\Persistence $persistence;
35 
36  public function __construct(Bucket $bucket, Persistence $persistence)
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&#39;m still alive! If your calculation takes a really long time don&#39;t forget to use the heartbeat...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Job.php:19
notifyCurrentTask(Task $task)
If the current task changes notify the observer.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
notifyPercentage(Task $task, int $percentage)
You can change the progress of a currently running task.