events/Classes/Service/CleanupService.php
Daniel Siepmann 1f769939b4 Extend cleanup
Properly cleanup system.

Delete further records when deleting everything.
Also respect further records when purging old entries.

Respect:

* sys_category_record_mm
* sys_file_reference
* sys_file_metadata
2021-09-07 12:19:09 +02:00

38 lines
761 B
PHP

<?php
namespace Wrm\Events\Service;
use Wrm\Events\Service\Cleanup\Database;
use Wrm\Events\Service\Cleanup\Files;
class CleanupService
{
/**
* @var Database
*/
private $database;
/**
* @var Files
*/
private $files;
public function __construct(Database $database, Files $files)
{
$this->database = $database;
$this->files = $files;
}
public function deleteAllData(): void
{
$this->database->truncateTables();
$this->files->deleteAll();
}
public function deletePastData(): void
{
$this->database->deleteDates(...$this->database->getPastDates());
$this->database->deleteEventsWithoutDates();
$this->files->deleteDangling();
}
}