mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
Feature: [Calendar doc] complete CRUD for associating documents within Calendar
This commit is contained in:
@@ -11,6 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Entity;
|
||||
|
||||
use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocCreateDTO;
|
||||
use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocEditDTO;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
@@ -52,14 +54,14 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"})
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private StoredObject $storedObject;
|
||||
private ?StoredObject $storedObject;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=false, options={"default": false})
|
||||
*/
|
||||
private bool $trackDateTimeVersion = false;
|
||||
|
||||
public function __construct(Calendar $calendar, StoredObject $storedObject)
|
||||
public function __construct(Calendar $calendar, ?StoredObject $storedObject)
|
||||
{
|
||||
$this->setCalendar($calendar);
|
||||
|
||||
@@ -67,6 +69,22 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
||||
$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;
|
||||
|
Reference in New Issue
Block a user