From 6784ee9ead7152b608d16128754385c72fc54300 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 19 Mar 2026 10:06:08 +0100 Subject: [PATCH] feat : add TaskRecurrence entity with RecurrenceType enum Co-Authored-By: Claude Sonnet 4.6 --- src/Entity/TaskRecurrence.php | 197 ++++++++++++++++++++ src/Repository/TaskRecurrenceRepository.php | 17 ++ 2 files changed, 214 insertions(+) create mode 100644 src/Entity/TaskRecurrence.php create mode 100644 src/Repository/TaskRecurrenceRepository.php diff --git a/src/Entity/TaskRecurrence.php b/src/Entity/TaskRecurrence.php new file mode 100644 index 0000000..a6a6dc5 --- /dev/null +++ b/src/Entity/TaskRecurrence.php @@ -0,0 +1,197 @@ + ['task_recurrence:read']], + denormalizationContext: ['groups' => ['task_recurrence:write']], +)] +#[ORM\Entity(repositoryClass: TaskRecurrenceRepository::class)] +class TaskRecurrence +{ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column] + #[Groups(['task_recurrence:read', 'task:read'])] + private ?int $id = null; + + #[ORM\Column(type: 'string', enumType: RecurrenceType::class)] + #[Groups(['task_recurrence:read', 'task_recurrence:write', 'task:read'])] + private ?RecurrenceType $type = null; + + #[ORM\Column(type: 'integer')] + #[Groups(['task_recurrence:read', 'task_recurrence:write', 'task:read'])] + private int $interval = 1; + + #[ORM\Column(type: 'json', nullable: true)] + #[Groups(['task_recurrence:read', 'task_recurrence:write', 'task:read'])] + private ?array $daysOfWeek = null; + + #[ORM\Column(type: 'integer', nullable: true)] + #[Groups(['task_recurrence:read', 'task_recurrence:write', 'task:read'])] + private ?int $dayOfMonth = null; + + #[ORM\Column(type: 'integer', nullable: true)] + #[Groups(['task_recurrence:read', 'task_recurrence:write', 'task:read'])] + private ?int $weekOfMonth = null; + + #[ORM\Column(type: 'date_immutable', nullable: true)] + #[Groups(['task_recurrence:read', 'task_recurrence:write', 'task:read'])] + private ?DateTimeImmutable $endDate = null; + + #[ORM\Column(type: 'integer', nullable: true)] + #[Groups(['task_recurrence:read', 'task_recurrence:write', 'task:read'])] + private ?int $maxOccurrences = null; + + #[ORM\Column(type: 'integer')] + #[Groups(['task_recurrence:read'])] + private int $occurrenceCount = 0; + + #[ORM\Version] + #[ORM\Column(type: 'integer')] + private int $version = 1; + + /** @var Collection */ + #[ORM\OneToMany(targetEntity: Task::class, mappedBy: 'recurrence')] + private Collection $tasks; + + public function __construct() + { + $this->tasks = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getType(): ?RecurrenceType + { + return $this->type; + } + + public function setType(RecurrenceType $type): static + { + $this->type = $type; + + return $this; + } + + public function getInterval(): int + { + return $this->interval; + } + + public function setInterval(int $interval): static + { + $this->interval = $interval; + + return $this; + } + + public function getDaysOfWeek(): ?array + { + return $this->daysOfWeek; + } + + public function setDaysOfWeek(?array $daysOfWeek): static + { + $this->daysOfWeek = $daysOfWeek; + + return $this; + } + + public function getDayOfMonth(): ?int + { + return $this->dayOfMonth; + } + + public function setDayOfMonth(?int $dayOfMonth): static + { + $this->dayOfMonth = $dayOfMonth; + + return $this; + } + + public function getWeekOfMonth(): ?int + { + return $this->weekOfMonth; + } + + public function setWeekOfMonth(?int $weekOfMonth): static + { + $this->weekOfMonth = $weekOfMonth; + + return $this; + } + + public function getEndDate(): ?DateTimeImmutable + { + return $this->endDate; + } + + public function setEndDate(?DateTimeImmutable $endDate): static + { + $this->endDate = $endDate; + + return $this; + } + + public function getMaxOccurrences(): ?int + { + return $this->maxOccurrences; + } + + public function setMaxOccurrences(?int $maxOccurrences): static + { + $this->maxOccurrences = $maxOccurrences; + + return $this; + } + + public function getOccurrenceCount(): int + { + return $this->occurrenceCount; + } + + public function getVersion(): int + { + return $this->version; + } + + /** @return Collection */ + public function getTasks(): Collection + { + return $this->tasks; + } + + public function incrementOccurrenceCount(): static + { + ++$this->occurrenceCount; + + return $this; + } +} diff --git a/src/Repository/TaskRecurrenceRepository.php b/src/Repository/TaskRecurrenceRepository.php new file mode 100644 index 0000000..b73eb6b --- /dev/null +++ b/src/Repository/TaskRecurrenceRepository.php @@ -0,0 +1,17 @@ +