2019-08-12 07:43:37 +02:00
|
|
|
<?php
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Events\Service;
|
2019-08-12 07:43:37 +02:00
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
use WerkraumMedia\Events\Service\Cleanup\Database;
|
|
|
|
use WerkraumMedia\Events\Service\Cleanup\Files;
|
2019-09-17 17:14:28 +02:00
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
final class CleanupService
|
2019-09-17 17:14:28 +02:00
|
|
|
{
|
2023-11-27 10:04:42 +01:00
|
|
|
public function __construct(
|
|
|
|
private readonly Database $database,
|
|
|
|
private readonly Files $files
|
|
|
|
) {
|
2019-09-17 17:14:28 +02:00
|
|
|
}
|
|
|
|
|
2021-09-07 09:52:14 +02:00
|
|
|
public function deleteAllData(): void
|
2019-09-19 10:47:37 +02:00
|
|
|
{
|
2021-09-07 09:49:03 +02:00
|
|
|
$this->database->truncateTables();
|
2021-12-16 14:07:32 +01:00
|
|
|
$this->files->deleteDangling();
|
2019-09-19 10:47:37 +02:00
|
|
|
}
|
|
|
|
|
2021-09-07 09:52:14 +02:00
|
|
|
public function deletePastData(): void
|
2019-09-19 10:47:37 +02:00
|
|
|
{
|
2021-12-20 09:45:25 +01:00
|
|
|
$this->database->deletePastDates();
|
2021-09-07 09:49:03 +02:00
|
|
|
$this->database->deleteEventsWithoutDates();
|
2019-09-19 12:11:21 +02:00
|
|
|
$this->files->deleteDangling();
|
2019-09-19 10:47:37 +02:00
|
|
|
}
|
2019-09-17 17:14:28 +02:00
|
|
|
}
|