timeEntryRepository->find($id); if (null === $entry) { throw new InvalidArgumentException(sprintf('TimeEntry with ID %d not found.', $id)); } if (null !== $title) { $entry->setTitle($title); } if (null !== $startedAt) { $entry->setStartedAt(new DateTimeImmutable($startedAt)); } if (null !== $stoppedAt) { $entry->setStoppedAt(new DateTimeImmutable($stoppedAt)); } if (null !== $description) { $entry->setDescription($description); } if (null !== $projectId) { $project = $this->projectRepository->find($projectId); if (null === $project) { throw new InvalidArgumentException(sprintf('Project with ID %d not found.', $projectId)); } $entry->setProject($project); } if (null !== $taskId) { $task = $this->taskRepository->find($taskId); if (null === $task) { throw new InvalidArgumentException(sprintf('Task with ID %d not found.', $taskId)); } $entry->setTask($task); } if (null !== $clientTicketId) { $clientTicket = $this->clientTicketRepository->find($clientTicketId); if (null === $clientTicket) { throw new InvalidArgumentException(sprintf('ClientTicket with ID %d not found.', $clientTicketId)); } $entry->setClientTicket($clientTicket); } if (null !== $tagIds) { foreach ($entry->getTags()->toArray() as $existingTag) { $entry->removeTag($existingTag); } foreach ($tagIds as $tagId) { $tag = $this->taskTagRepository->find($tagId); if (null === $tag) { throw new InvalidArgumentException(sprintf('TaskTag with ID %d not found.', $tagId)); } $entry->addTag($tag); } } $this->entityManager->flush(); return json_encode(Serializer::timeEntry($entry)); } }