src/Entity/BC/Dictionary.php line 9

Open in your IDE?
  1. <?php
  2. namespace App\Entity\BC;
  3. use Doctrine\ORM\Mapping as ORM;
  4. #[ORM\MappedSuperclass]
  5. #[ORM\HasLifecycleCallbacks]
  6. abstract class Dictionary
  7. {
  8.     #[ORM\Id]
  9.     #[ORM\Column(type'integer')]
  10.     protected int $id;
  11.     #[ORM\Column(type'string'length255nullabletrue)]
  12.     protected ?string $name null;
  13.     #[ORM\Column(type'datetime_immutable')]
  14.     protected \DateTimeImmutable $createdAt;
  15.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  16.     protected ?\DateTimeImmutable $updatedAt null;
  17.     public function __construct(int $id)
  18.     {
  19.         $this->id $id;
  20.     }
  21.     public function __toString(): string
  22.     {
  23.         return (string) $this->name;
  24.     }
  25.     #[ORM\PrePersist]
  26.     public function onPrePersist(): void
  27.     {
  28.         $now = new \DateTimeImmutable();
  29.         $this->createdAt $now;
  30.     }
  31.     #[ORM\PreUpdate]
  32.     public function onPreUpdate(): void
  33.     {
  34.         $this->updatedAt = new \DateTimeImmutable();
  35.     }
  36.     public function getId(): int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function setName(?string $name): void
  45.     {
  46.         $this->name $name;
  47.     }
  48.     public function getCreatedAt(): \DateTimeImmutable
  49.     {
  50.         return $this->createdAt;
  51.     }
  52.     public function getUpdatedAt(): ?\DateTimeImmutable
  53.     {
  54.         return $this->updatedAt;
  55.     }
  56. }