Skip to content

Commit a982c1a

Browse files
committed
Component/Filesystem: contribute cron jobs
1 parent 68cd8eb commit a982c1a

3 files changed

Lines changed: 13 additions & 19 deletions

File tree

components/ILIAS/Filesystem/Filesystem.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,12 @@ public function init(
3636
new \ilFileSystemSetupAgent(
3737
$pull[\ILIAS\Refinery\Factory::class]
3838
);
39+
40+
$contribute[\ILIAS\Cron\CronJob::class] = static fn() =>
41+
new \ilFileSystemCleanTempDirCron(
42+
self::class,
43+
$use[\ILIAS\Language\Language::class],
44+
$use[\ILIAS\Logging\LoggerFactory::class]
45+
);
3946
}
4047
}

components/ILIAS/Filesystem/classes/class.ilFileSystemCleanTempDirCron.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,19 @@
2828
class ilFileSystemCleanTempDirCron extends ilCronJob
2929
{
3030
protected \ILIAS\Filesystem\Filesystem $filesystem;
31-
32-
protected ilLanguage $language;
33-
3431
protected ilLogger $logger;
3532

36-
/**
37-
* @inheritDoc
38-
*/
39-
public function __construct()
33+
public function init(): void
4034
{
35+
$this->logger = $this->logger_factory->getRootLogger();
36+
4137
/**
4238
* @var $DIC Container
4339
*/
4440
global $DIC;
45-
if ($DIC->offsetExists('lng')) {
46-
$this->language = $DIC['lng'];
47-
}
4841
if ($DIC->offsetExists('filesystem')) {
4942
$this->filesystem = $DIC->filesystem()->temp();
5043
}
51-
if ($DIC->offsetExists('ilLoggerFactory')) {
52-
$this->logger = $DIC->logger()->root();
53-
}
5444
}
5545

5646
private function initDependencies(): void
@@ -64,12 +54,12 @@ public function getId(): string
6454

6555
public function getTitle(): string
6656
{
67-
return $this->language->txt('file_system_clean_temp_dir_cron');
57+
return $this->lng->txt('file_system_clean_temp_dir_cron');
6858
}
6959

7060
public function getDescription(): string
7161
{
72-
return $this->language->txt("file_system_clean_temp_dir_cron_info");
62+
return $this->lng->txt("file_system_clean_temp_dir_cron_info");
7363
}
7464

7565
public function hasAutoActivation(): bool
@@ -128,7 +118,7 @@ public function run(): ilCronJobResult
128118
$folders = $this->filesystem->finder()->in([""]);
129119
$folders = $folders->directories();
130120
$folders = $folders->date($date);
131-
$folders = $folders->sort(fn (
121+
$folders = $folders->sort(fn(
132122
Metadata $a,
133123
Metadata $b
134124
): int => strlen($a->getPath()) - strlen($b->getPath()));

components/ILIAS/Filesystem/service.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@
33
id="filesys">
44
<baseclasses>
55
</baseclasses>
6-
<crons>
7-
<cron id="file_system_clean_temp_dir" class="ilFileSystemCleanTempDirCron" />
8-
</crons>
96
</service>

0 commit comments

Comments
 (0)