48 if (
$DIC->offsetExists(
'lng')) {
51 if (
$DIC->offsetExists(
'filesystem')) {
52 $this->
filesystem = $DIC->filesystem()->temp();
54 if (
$DIC->offsetExists(
'ilLoggerFactory')) {
55 $this->
logger = $DIC->logger()->root();
65 return "file_system_clean_temp_dir";
70 return $this->
language->txt(
'file_system_clean_temp_dir_cron');
75 return $this->
language->txt(
"file_system_clean_temp_dir_cron_info");
90 return JobScheduleType::DAILY;
102 $date =
"until 10 day ago";
105 $files = $this->
filesystem->finder()->in([
""]);
106 $files = $files->files();
107 $files = $files->date($date);
108 $files = $files->getIterator();
111 while ($files->valid()) {
113 $file_match = $files->current();
114 $path = $file_match->getPath();
115 if ($file_match->isFile()) {
117 $deleted_files[] =
$path;
120 }
catch (Throwable $t) {
122 "Cron Job \"Clean temp directory\" could not delete " .
$path
123 .
"due to the following exception: " . $t->getMessage()
131 $folders = $this->
filesystem->finder()->in([
""]);
132 $folders = $folders->directories();
133 $folders = $folders->date($date);
134 $folders = $folders->sort(fn(
137 ):
int => strlen(
$a->getPath()) - strlen(
$b->getPath()));
138 $folders = $folders->reverseSorting();
139 $folders = $folders->getIterator();
141 $deleted_folders = [];
144 while ($folders->valid()) {
146 $folder_match = $folders->current();
147 $path = $folder_match->getPath();
148 if ($folder_match->isDir()) {
150 $deleted_folders[] =
$path;
153 }
catch (Throwable $t) {
155 "Cron Job \"Clean temp directory\" could not delete " .
$path
156 .
"due to the following exception: " . $t->getMessage()
162 $num_folders = count($deleted_folders);
163 $num_files = count($deleted_files);
166 $result->setMessage($num_folders .
" folders and " . $num_files .
" files have been deleted.");
167 $result->setStatus(JobResult::STATUS_OK);
Customizing of pimple-DIC for ILIAS.
Class ilFileSystemCleanTempDirCron.
getDefaultScheduleValue()
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
Component logger with individual log levels by component id.
The filesystem interface provides the public interface for the Filesystem service API consumer.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples