diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index 9152c96be..69f2c1216 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; +use Chill\MainBundle\Doctrine\Model\TrackCreationTrait; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; +use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface; @@ -34,6 +36,8 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Table(name: 'chill_person_accompanying_period_work')] class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, TrackCreationInterface, TrackUpdateInterface { + use TrackCreationTrait; + use TrackUpdateTrait; #[Serializer\Groups(['read', 'read:accompanyingPeriodWork:light'])] #[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)] #[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['read:accompanyingPeriodWork:light'])] @@ -50,10 +54,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues #[ORM\OrderBy(['startDate' => \Doctrine\Common\Collections\Criteria::DESC, 'id' => 'DESC'])] private Collection $accompanyingPeriodWorkEvaluations; - #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] - private ?\DateTimeImmutable $createdAt = null; - #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] private bool $createdAutomatically = false; @@ -62,11 +62,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)] private string $createdAutomaticallyReason = ''; - #[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] - #[ORM\ManyToOne(targetEntity: User::class)] - #[ORM\JoinColumn(nullable: false)] - private ?User $createdBy = null; - #[Serializer\Groups(['accompanying_period_work:create', 'accompanying_period_work:edit', 'read', 'docgen:read', 'read:accompanyingPeriodWork:light'])] #[Assert\GreaterThanOrEqual(propertyPath: 'startDate', message: 'accompanying_course_work.The endDate should be greater or equal than the start date')] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])] @@ -136,15 +131,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues #[ORM\JoinTable(name: 'chill_person_accompanying_period_work_third_party')] // In schema : intervenants private Collection $thirdParties; - #[Serializer\Groups(['read', 'docgen:read'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)] - private ?\DateTimeImmutable $updatedAt = null; - - #[Serializer\Groups(['read', 'docgen:read'])] - #[ORM\ManyToOne(targetEntity: User::class)] - #[ORM\JoinColumn(nullable: false)] - private ?User $updatedBy = null; - #[Serializer\Groups(['read', 'accompanying_period_work:edit'])] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false, options: ['default' => 1])] #[ORM\Version] @@ -231,11 +217,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->accompanyingPeriodWorkEvaluations; } - public function getCreatedAt(): ?\DateTimeImmutable - { - return $this->createdAt; - } - public function getCreatedAutomatically(): ?bool { return $this->createdAutomatically; @@ -246,11 +227,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->createdAutomaticallyReason; } - public function getCreatedBy(): ?User - { - return $this->createdBy; - } - public function getEndDate(): ?\DateTimeInterface { return $this->endDate; @@ -365,16 +341,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->getThirdParties(); } - public function getUpdatedAt(): ?\DateTimeImmutable - { - return $this->updatedAt; - } - - public function getUpdatedBy(): ?User - { - return $this->updatedBy; - } - public function getVersion(): int { return $this->version; @@ -470,13 +436,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } - public function setCreatedAt(\DateTimeInterface $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - public function setCreatedAutomatically(bool $createdAutomatically): self { $this->createdAutomatically = $createdAutomatically; @@ -491,13 +450,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } - public function setCreatedBy(?User $user): self - { - $this->createdBy = $user; - - return $this; - } - public function setEndDate(?\DateTimeInterface $endDate = null): self { $this->endDate = $endDate; @@ -539,18 +491,4 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } - - public function setUpdatedAt(\DateTimeInterface $datetime): TrackUpdateInterface - { - $this->updatedAt = $datetime instanceof \DateTime ? \DateTimeImmutable::createFromMutable($datetime) : $datetime; - - return $this; - } - - public function setUpdatedBy(User $user): TrackUpdateInterface - { - $this->updatedBy = $user; - - return $this; - } } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20250527122841.php b/src/Bundle/ChillPersonBundle/migrations/Version20250527122841.php new file mode 100644 index 000000000..d9c285e00 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20250527122841.php @@ -0,0 +1,51 @@ +addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER createdby_id DROP NOT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER updatedby_id DROP NOT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER createdat DROP NOT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER updatedat DROP NOT NULL + SQL); + } + + public function down(Schema $schema): void + { + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER createdAt SET NOT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER updatedAt SET NOT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER createdBy_id SET NOT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE chill_person_accompanying_period_work ALTER updatedBy_id SET NOT NULL + SQL); + } +}