Skip to content

Commit ed0eee2

Browse files
committed
Component/Forum: contribute cron jobs
1 parent 17b4849 commit ed0eee2

3 files changed

Lines changed: 23 additions & 28 deletions

File tree

components/ILIAS/Forum/Forum.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ public function init(
3838
);
3939
$contribute[Component\Resource\PublicAsset::class] = fn() =>
4040
new Component\Resource\ComponentJS($this, "autosave_forum.js");
41+
4142
$contribute[Component\Resource\PublicAsset::class] = fn() =>
42-
new Component\Resource\ComponentCSS($this, "forum_table.css");
43+
new Component\Resource\ComponentCSS($this, "forum_table.css");
44+
45+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
46+
new \ilForumCronNotification(
47+
self::class,
48+
$use[\ILIAS\Language\Language::class],
49+
$use[\ILIAS\Logging\LoggerFactory::class]
50+
);
4351
}
4452
}

components/ILIAS/Forum/classes/class.ilForumCronNotification.php

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,24 @@ class ilForumCronNotification extends ilCronJob
4141
/** @var array<int, ilObjCourse|ilObjGroup|null> */
4242
private static array $container_by_frm_ref_id = [];
4343

44-
private readonly ilLanguage $lng;
45-
private readonly ilSetting $settings;
44+
private ilSetting $settings;
4645
private ilLogger $logger;
4746
private ilTree $tree;
4847
private int $num_sent_messages = 0;
49-
private readonly ilDBInterface $ilDB;
50-
private readonly ilForumNotificationCache $notificationCache;
51-
private readonly \ILIAS\Refinery\Factory $refinery;
52-
private readonly ilCronManager $cronManager;
53-
54-
public function __construct(
55-
ilDBInterface $database = null,
56-
ilForumNotificationCache $notificationCache = null,
57-
ilLanguage $lng = null,
58-
ilSetting $settings = null,
59-
\ILIAS\Refinery\Factory $refinery = null,
60-
ilCronManager $cronManager = null
61-
) {
62-
global $DIC;
48+
private ilDBInterface $ilDB;
49+
private ilForumNotificationCache $notificationCache;
50+
private \ILIAS\Refinery\Factory $refinery;
51+
private ilCronManager $cronManager;
6352

64-
$this->settings = $settings ?? new ilSetting('frma');
65-
$this->lng = $lng ?? $DIC->language();
66-
$this->ilDB = $database ?? $DIC->database();
67-
$this->notificationCache = $notificationCache ?? new ilForumNotificationCache();
68-
$this->refinery = $refinery ?? $DIC->refinery();
69-
$this->cronManager = $cronManager ?? $DIC->cron()->manager();
53+
public function init(): void
54+
{
55+
$this->logger = $this->logger_factory->getLogger('frm');
56+
global $DIC;
57+
$this->settings = new ilSetting('frma');
58+
$this->ilDB = $DIC->database();
59+
$this->notificationCache = new ilForumNotificationCache();
60+
$this->refinery = $DIC->refinery();
61+
$this->cronManager = $DIC->cron()->manager();
7062
}
7163

7264
public function getId(): string
@@ -119,8 +111,6 @@ public function keepAlive(): void
119111
public function run(): ilCronJobResult
120112
{
121113
global $DIC;
122-
123-
$this->logger = $DIC->logger()->frm();
124114
$this->tree = $DIC->repositoryTree();
125115

126116
$status = ilCronJobResult::STATUS_NO_ACTION;

components/ILIAS/Forum/module.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
<event type="raise" id="mergedThreads" />
3333
<event type="raise" id="movedThreads" />
3434
</events>
35-
<crons>
36-
<cron id="frm_notification" class="ilForumCronNotification" />
37-
</crons>
3835
<logging />
3936
<gsproviders>
4037
<gsprovider purpose="tools" class_name="ilForumGlobalScreenToolsProvider" />

0 commit comments

Comments
 (0)