Add comments to tasks
Everyone who may change a task's status (attached subcontractors too) comments on it on the job page. Authors edit and remove their own comments; admin and management may remove anyone's (jobs.remove-any-task-comment). Edited comments show when they were edited, and task cards show the number of comments. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Modules\Jobs\Domain\Contracts\TaskCommentRepository;
|
||||
use App\Modules\Jobs\Domain\Entities\TaskComment;
|
||||
|
||||
class InMemoryTaskCommentRepository implements TaskCommentRepository
|
||||
{
|
||||
/** @var array<int, TaskComment> */
|
||||
public array $comments = [];
|
||||
|
||||
private int $nextId = 1;
|
||||
|
||||
public function findForTask(int $taskId, int $commentId): ?TaskComment
|
||||
{
|
||||
$comment = $this->comments[$commentId] ?? null;
|
||||
|
||||
return $comment !== null && $comment->taskId() === $taskId ? clone $comment : null;
|
||||
}
|
||||
|
||||
public function save(TaskComment $comment): TaskComment
|
||||
{
|
||||
$id = $comment->id() ?? $this->nextId++;
|
||||
$this->comments[$id] = TaskComment::reconstitute($id, $comment->taskId(), $comment->authorId(), $comment->body(), $comment->createdAt(), $comment->editedAt());
|
||||
|
||||
return clone $this->comments[$id];
|
||||
}
|
||||
|
||||
public function delete(TaskComment $comment): void
|
||||
{
|
||||
unset($this->comments[$comment->id()]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user