From 7af7135971d2436545cc6cdf51bbe79a464c7c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 26 Jan 2022 21:51:13 +0100 Subject: [PATCH] use trait to implement TrackCreationInterface and TrackUpdateInterface --- .../Entity/Person/PersonResource.php | 76 +------------------ 1 file changed, 4 insertions(+), 72 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index 2e8441511..bc792ef95 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -12,7 +12,9 @@ declare(strict_types=1); namespace Chill\PersonBundle\Entity\Person; 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\CommentEmbeddable; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\Person; @@ -34,23 +36,14 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; */ class PersonResource implements TrackCreationInterface, TrackUpdateInterface { + use TrackCreationTrait; + use TrackUpdateTrait; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") * @Groups({"read"}) */ private CommentEmbeddable $comment; - /** - * @ORM\Column(type="datetime") - */ - private $createdAt; - - /** - * @ORM\ManyToOne(targetEntity=User::class) - * @ORM\JoinColumn(nullable=false) - */ - private User $createdBy; - /** * @ORM\Column(type="text", nullable=true) * @Groups({"read"}) @@ -92,16 +85,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface */ private ?ThirdParty $thirdParty = null; - /** - * @ORM\Column(type="datetime", nullable=true) - */ - private $updatedAt; - - /** - * @ORM\ManyToOne(targetEntity=User::class) - */ - private User $updatedBy; - public function __construct() { $this->comment = new CommentEmbeddable(); @@ -112,16 +95,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this->comment; } - public function getCreatedAt(): ?DateTimeInterface - { - return $this->createdAt; - } - - public function getCreatedBy(): ?User - { - return $this->createdBy; - } - public function getFreeText(): ?string { return $this->freeText; @@ -155,16 +128,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this->thirdParty; } - public function getUpdatedAt(): ?DateTimeInterface - { - return $this->updatedAt; - } - - public function getUpdatedBy(): ?User - { - return $this->updatedBy; - } - public function setComment(?CommentEmbeddable $comment): self { if (null === $comment) { @@ -178,23 +141,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setCreatedAt(DateTimeInterface $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function setCreatedBy(?User $createdBy): self - { - $this->createdBy = $createdBy; - - return $this; - } - - /** - * SETTERS. - */ public function setFreeText(?string $freeText): self { $this->freeText = $freeText; @@ -249,20 +195,6 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setUpdatedAt(DateTimeInterface $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function setUpdatedBy(?User $updatedBy): self - { - $this->updatedBy = $updatedBy; - - return $this; - } - /** * @Assert\Callback *