2019-08-12 07:43:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Wrm\Events\Service;
|
|
|
|
|
2019-09-19 12:11:21 +02:00
|
|
|
use Wrm\Events\Service\Cleanup\Database;
|
|
|
|
use Wrm\Events\Service\Cleanup\Files;
|
2019-09-17 17:14:28 +02:00
|
|
|
|
|
|
|
class CleanupService
|
|
|
|
{
|
2019-09-19 12:11:21 +02:00
|
|
|
/**
|
|
|
|
* @var Database
|
|
|
|
*/
|
|
|
|
private $database;
|
2019-09-19 09:09:42 +02:00
|
|
|
|
2019-09-19 12:11:21 +02:00
|
|
|
/**
|
|
|
|
* @var Files
|
|
|
|
*/
|
|
|
|
private $files;
|
2019-09-19 10:47:37 +02:00
|
|
|
|
2019-09-19 12:11:21 +02:00
|
|
|
public function __construct(Database $database, Files $files)
|
2019-09-17 17:14:28 +02:00
|
|
|
{
|
2019-09-19 12:11:21 +02:00
|
|
|
$this->database = $database;
|
|
|
|
$this->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
|
|
|
}
|