Skip to content

Commit 20210aa

Browse files
committed
Component/Forum: contribute cron jobs
1 parent b9c78fd commit 20210aa

3 files changed

Lines changed: 26 additions & 18 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+
'components\\' . self::class,
48+
$use[\ILIAS\Language\Language::class],
49+
true
50+
);
4351
}
4452
}

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ 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;
4544
private readonly ilSetting $settings;
4645
private ilLogger $logger;
4746
private ilTree $tree;
@@ -51,22 +50,26 @@ class ilForumCronNotification extends ilCronJob
5150
private readonly \ILIAS\Refinery\Factory $refinery;
5251
private readonly ilCronManager $cronManager;
5352

53+
5454
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
55+
string $component,
56+
\ILIAS\Language\Language $lng,
57+
bool $registration = false
6158
) {
62-
global $DIC;
59+
parent::__construct($component, $lng);
60+
if (!$registration) {
61+
$this->additionalConstruct();
62+
}
63+
}
6364

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();
65+
private function additionalConstruct()
66+
{
67+
global $DIC;
68+
$this->settings = new ilSetting('frma');
69+
$this->ilDB = $DIC->database();
70+
$this->notificationCache = new ilForumNotificationCache();
71+
$this->refinery = $DIC->refinery();
72+
$this->cronManager = $DIC->cron()->manager();
7073
}
7174

7275
public function getId(): string

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)