refactor(entity): use TrackCreationTrait and TrackUpdateTrait in AsideActivity

- Replace manual tracking of createdAt, createdBy, updatedAt, updatedBy with TrackCreationTrait and TrackUpdateTrait
- Remove related properties and methods
This commit is contained in:
2025-08-05 09:04:22 +02:00
parent 4c28a4c358
commit 4b484bd16c

View File

@@ -12,7 +12,9 @@ declare(strict_types=1);
namespace Chill\AsideActivityBundle\Entity;
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\User;
use Chill\MainBundle\Entity\Location;
use Doctrine\ORM\Mapping as ORM;
@@ -22,18 +24,14 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(schema: 'chill_asideactivity')]
class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
#[Assert\NotBlank]
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: false)]
private User $agent;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $createdAt = null;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: false)]
private User $createdBy;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $date = null;
@@ -56,27 +54,11 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
#[ORM\JoinColumn(nullable: false)]
private ?AsideActivityCategory $type = null;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $updatedAt = null;
#[ORM\ManyToOne(targetEntity: User::class)]
private User $updatedBy;
public function getAgent(): ?User
{
return $this->agent;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
@@ -107,16 +89,6 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
return $this->type;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setAgent(?User $agent): self
{
$this->agent = $agent;
@@ -124,20 +96,6 @@ class AsideActivity 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;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
@@ -172,18 +130,4 @@ class AsideActivity 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;
}
}