0])] private int $datetimeVersion = 0; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] private ?int $id = null; #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false, options: ['default' => false])] private bool $trackDateTimeVersion = false; public function __construct( Calendar $calendar, #[ORM\ManyToOne(targetEntity: StoredObject::class, cascade: ['persist'])] #[ORM\JoinColumn(nullable: false)] private ?StoredObject $storedObject ) { $this->setCalendar($calendar); $this->datetimeVersion = $calendar->getDateTimeVersion(); } public function createFromDTO(CalendarDocCreateDTO $calendarDocCreateDTO): void { $this->storedObject = $calendarDocCreateDTO->doc; $this->storedObject->setTitle($calendarDocCreateDTO->title); } public function editFromDTO(CalendarDocEditDTO $calendarDocEditDTO): void { if (null !== $calendarDocEditDTO->doc) { $calendarDocEditDTO->doc->setTitle($this->getStoredObject()->getTitle()); $this->setStoredObject($calendarDocEditDTO->doc); } $this->getStoredObject()->setTitle($calendarDocEditDTO->title); } public function getCalendar(): Calendar { return $this->calendar; } public function getDatetimeVersion(): int { return $this->datetimeVersion; } public function getId(): ?int { return $this->id; } public function getStoredObject(): StoredObject { return $this->storedObject; } public function isTrackDateTimeVersion(): bool { return $this->trackDateTimeVersion; } /** * @internal use @see{Calendar::removeDocument} instead */ public function setCalendar(?Calendar $calendar): CalendarDoc { if (null === $calendar) { $this->calendar->removeDocument($this); } else { $calendar->addDocument($this); } $this->calendar = $calendar; $this->datetimeVersion = $calendar->getDateTimeVersion(); return $this; } public function setDatetimeVersion(int $datetimeVersion): CalendarDoc { $this->datetimeVersion = $datetimeVersion; return $this; } public function setStoredObject(StoredObject $storedObject): CalendarDoc { $this->storedObject = $storedObject; return $this; } public function setTrackDateTimeVersion(bool $trackDateTimeVersion): CalendarDoc { $this->trackDateTimeVersion = $trackDateTimeVersion; return $this; } }