use trait to implement TrackCreationInterface and TrackUpdateInterface

This commit is contained in:
Julien Fastré 2022-01-26 21:51:13 +01:00
parent c70a4dc664
commit 7af7135971

View File

@ -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
*