mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-25 07:56:10 +01:00
Daniel Siepmann
1f769939b4
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
38 lines
761 B
PHP
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();
|
|
}
|
|
}
|