mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-10 08:16:09 +01:00
Daniel Siepmann
6aa4681cb9
Adjust existing code base to not use hardcoded file path. Instead use info from database and check all files which have references to event objects. Also add test to cover feature.
38 lines
766 B
PHP
38 lines
766 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->deleteDangling();
|
|
}
|
|
|
|
public function deletePastData(): void
|
|
{
|
|
$this->database->deleteDates(...$this->database->getPastDates());
|
|
$this->database->deleteEventsWithoutDates();
|
|
$this->files->deleteDangling();
|
|
}
|
|
}
|