Backup #707
| ID | 707 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/UseCases/Task/DeleteTaskUseCase.php |
| Version | 1 |
| Typ |
modified |
| Größe | 1.4 KB |
| Hash | 5309cdc62224984ade9174b799d4d6ce1a17a5391d50f00877d1626d49632025 |
| Datum | 2025-12-23 07:54:33 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace UseCases\Task;
use Infrastructure\Persistence\TaskRepository;
class DeleteTaskUseCase
{
private TaskRepository $taskRepository;
public function __construct(?TaskRepository $taskRepository = null)
{
$this->taskRepository = $taskRepository ?? new TaskRepository();
}
public function execute(int $taskId): bool
{
$task = $this->taskRepository->find($taskId);
if ($task === null) {
throw new \InvalidArgumentException("Task {$taskId} not found");
}
$subtasks = $this->taskRepository->findSubtasks($taskId);
if (count($subtasks) > 0) {
throw new \InvalidArgumentException(
'Cannot delete task with subtasks. Delete subtasks first or use cascade delete.'
);
}
return $this->taskRepository->delete($taskId);
}
public function executeCascade(int $taskId): int
{
$task = $this->taskRepository->find($taskId);
if ($task === null) {
throw new \InvalidArgumentException("Task {$taskId} not found");
}
$deleted = 0;
$subtasks = $this->taskRepository->findSubtasks($taskId);
foreach ($subtasks as $subtask) {
$deleted += $this->executeCascade($subtask->getId());
}
$this->taskRepository->delete($taskId);
$deleted++;
return $deleted;
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 825 |
2 |
modified |
1.5 KB |
2025-12-23 08:14 |
| 707 |
1 |
modified |
1.4 KB |
2025-12-23 07:54 |
← Zurück zur Übersicht