mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 16:45:01 +00:00
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:
@@ -12,7 +12,9 @@ declare(strict_types=1);
|
|||||||
namespace Chill\AsideActivityBundle\Entity;
|
namespace Chill\AsideActivityBundle\Entity;
|
||||||
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Entity\Location;
|
use Chill\MainBundle\Entity\Location;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
@@ -22,18 +24,14 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
#[ORM\Table(schema: 'chill_asideactivity')]
|
#[ORM\Table(schema: 'chill_asideactivity')]
|
||||||
class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
||||||
{
|
{
|
||||||
|
use TrackCreationTrait;
|
||||||
|
|
||||||
|
use TrackUpdateTrait;
|
||||||
#[Assert\NotBlank]
|
#[Assert\NotBlank]
|
||||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
private User $agent;
|
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)]
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
|
||||||
private ?\DateTimeInterface $date = null;
|
private ?\DateTimeInterface $date = null;
|
||||||
|
|
||||||
@@ -56,27 +54,11 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
private ?AsideActivityCategory $type = null;
|
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
|
public function getAgent(): ?User
|
||||||
{
|
{
|
||||||
return $this->agent;
|
return $this->agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCreatedAt(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCreatedBy(): ?User
|
|
||||||
{
|
|
||||||
return $this->createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDate(): ?\DateTimeInterface
|
public function getDate(): ?\DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->date;
|
return $this->date;
|
||||||
@@ -107,16 +89,6 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdatedAt(): ?\DateTimeInterface
|
|
||||||
{
|
|
||||||
return $this->updatedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUpdatedBy(): ?User
|
|
||||||
{
|
|
||||||
return $this->updatedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAgent(?User $agent): self
|
public function setAgent(?User $agent): self
|
||||||
{
|
{
|
||||||
$this->agent = $agent;
|
$this->agent = $agent;
|
||||||
@@ -124,20 +96,6 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return $this;
|
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
|
public function setDate(\DateTimeInterface $date): self
|
||||||
{
|
{
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
@@ -172,18 +130,4 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
|
||||||
{
|
|
||||||
$this->updatedAt = $updatedAt;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUpdatedBy(?User $updatedBy): self
|
|
||||||
{
|
|
||||||
$this->updatedBy = $updatedBy;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user