Backup #830
| ID | 830 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/UseCases/Task/UpdateTaskStatusUseCase.php |
| Version | 2 |
| Typ |
modified |
| Größe | 2.5 KB |
| Hash | 6c9f0709029f076134572a9773c59d8b3bdd6ce12efc67ab4e9cec7659cbba56 |
| Datum | 2025-12-23 08:15:36 |
| 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\ValueObject\TaskStatus;
use Infrastructure\Persistence\TaskCommentRepository;
use Infrastructure\Persistence\TaskRepository;
class UpdateTaskStatusUseCase
{
private TaskRepository $taskRepository;
private TaskCommentRepository $commentRepository;
public function __construct(
?TaskRepository $taskRepository = null,
?TaskCommentRepository $commentRepository = null
) {
$this->taskRepository = $taskRepository ?? new TaskRepository();
$this->commentRepository = $commentRepository ?? new TaskCommentRepository();
}
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");
}
$newStatusEnum = TaskStatus::from($newStatus);
$oldStatus = $task->getStatus();
if (!$oldStatus->canTransitionTo($newStatusEnum)) {
throw new \InvalidArgumentException(
"Cannot transition from {$oldStatus->value} to {$newStatus}"
);
}
$task->setStatus($newStatusEnum);
$this->taskRepository->update($task);
$comment = TaskComment::createStatusChange(
$taskId,
$updatedBy,
$updatedByType,
$oldStatus->label(),
$newStatusEnum->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