Backup #2071
| ID | 2071 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/UseCases/Task/UpdateTaskStatusUseCase.php |
| Version | 4 |
| Typ |
modified |
| Größe | 2.2 KB |
| Hash | aecc7945740b4160877ad6b02298506d8c51b8190e97c77a2add41a22bca435b |
| Datum | 2025-12-28 23:32:45 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace UseCases\Task;
// @responsibility: Aktualisiert Task-Status mit Workflow-Validierung
use Domain\Entity\Task;
use Domain\Entity\TaskComment;
use Domain\Repository\TaskRepositoryInterface;
use Infrastructure\Persistence\TaskCommentRepository;
class UpdateTaskStatusUseCase
{
public function __construct(
private TaskRepositoryInterface $taskRepository,
private TaskCommentRepository $commentRepository
) {
}
public function execute(int $taskId, string $newStatus, string $updatedBy, string $updatedByType = 'human'): Task
{
$task = $this->taskRepository->find($taskId);
if ($task === null) {
throw new \InvalidArgumentException("Task {$taskId} not found");
}
$oldStatus = $task->getStatus();
match ($newStatus) {
'in_progress' => $task->start(),
'completed' => $task->complete(),
'failed' => $task->fail(),
'cancelled' => $task->cancel(),
'pending' => $task->retry(),
default => throw new \InvalidArgumentException("Invalid status: {$newStatus}"),
};
$this->taskRepository->update($task);
$comment = TaskComment::createStatusChange(
$taskId,
$updatedBy,
$updatedByType,
$oldStatus->label(),
$task->getStatus()->label()
);
$this->commentRepository->save($comment);
return $task;
}
public function startTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task
{
return $this->execute($taskId, 'in_progress', $updatedBy, $updatedByType);
}
public function completeTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task
{
return $this->execute($taskId, 'completed', $updatedBy, $updatedByType);
}
public function failTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task
{
return $this->execute($taskId, 'failed', $updatedBy, $updatedByType);
}
public function cancelTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task
{
return $this->execute($taskId, 'cancelled', $updatedBy, $updatedByType);
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 2072 |
5 |
modified |
2.4 KB |
2025-12-28 23:32 |
| 2071 |
4 |
modified |
2.2 KB |
2025-12-28 23:32 |
| 1458 |
3 |
modified |
2.2 KB |
2025-12-25 17:01 |
| 830 |
2 |
modified |
2.5 KB |
2025-12-23 08:15 |
| 710 |
1 |
modified |
2.4 KB |
2025-12-23 07:55 |
← Zurück zur Übersicht