<?php
namespace App\Entity\BC;
use Doctrine\ORM\Mapping as ORM;
#[ORM\MappedSuperclass]
#[ORM\HasLifecycleCallbacks]
abstract class Dictionary
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
protected int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
protected ?string $name = null;
#[ORM\Column(type: 'datetime_immutable')]
protected \DateTimeImmutable $createdAt;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
protected ?\DateTimeImmutable $updatedAt = null;
public function __construct(int $id)
{
$this->id = $id;
}
public function __toString(): string
{
return (string) $this->name;
}
#[ORM\PrePersist]
public function onPrePersist(): void
{
$now = new \DateTimeImmutable();
$this->createdAt = $now;
}
#[ORM\PreUpdate]
public function onPreUpdate(): void
{
$this->updatedAt = new \DateTimeImmutable();
}
public function getId(): int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): void
{
$this->name = $name;
}
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
}