src/Entity/News.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\MainTranslationTrait;
  4. use App\Entity\Translation\NewsTranslation;
  5. use App\Repository\NewsRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Gedmo\Translatable\Translatable;
  9. #[Gedmo\TranslationEntity(class: self::TRANSLATION_ENTITY)]
  10. #[ORM\Entity(repositoryClassNewsRepository::class)]
  11. #[ORM\HasLifecycleCallbacks]
  12. class News implements Translatable
  13. {
  14.     use MainTranslationTrait;
  15.     const TRANSLATION_ENTITY NewsTranslation::class;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(type'integer'nullabletrue)]
  21.     private ?int $type;
  22.     #[ORM\Column(type'string'nullabletrue)]
  23.     #[Gedmo\Translatable]
  24.     private ?string $title;
  25.     #[ORM\Column(type'string'nullabletrue)]
  26.     private ?string $image;
  27.     #[ORM\Column(type'string'length65nullabletrue)]
  28.     #[Gedmo\Translatable]
  29.     private ?string $metaTitle null;
  30.     #[ORM\Column(type'string'length165nullabletrue)]
  31.     #[Gedmo\Translatable]
  32.     private ?string $metaDescription null;
  33.     #[ORM\Column(type'string'nullabletrue)]
  34.     private ?string $metaImage null;
  35.     #[ORM\Column(type'text'nullabletrue)]
  36.     #[Gedmo\Translatable]
  37.     private mixed $description;
  38.     #[ORM\Column(type'string'nullabletrue)]
  39.     #[Gedmo\Translatable]
  40.     private ?string $shortDescription;
  41.     #[ORM\Column(type'datetime'nullabletrue)]
  42.     private ?\DateTimeInterface $createdAt null;
  43.     #[ORM\PrePersist]
  44.     public function onPrePersist(): void
  45.     {
  46.         $now = new \DateTimeImmutable();
  47.         if ($this->createdAt === null) {
  48.             $this->createdAt $now;
  49.         }
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     /**
  56.      * @return int|null
  57.      */
  58.     public function getType(): ?int
  59.     {
  60.         return $this->type;
  61.     }
  62.     /**
  63.      * @param int|null $type
  64.      */
  65.     public function setType(?int $type): void
  66.     {
  67.         $this->type $type;
  68.     }
  69.     /**
  70.      * @return string|null
  71.      */
  72.     public function getTitle(): ?string
  73.     {
  74.         return $this->title;
  75.     }
  76.     /**
  77.      * @param string|null $title
  78.      */
  79.     public function setTitle(?string $title): void
  80.     {
  81.         $this->title $title;
  82.     }
  83.     /**
  84.      * @return string|null
  85.      */
  86.     public function getImage(): ?string
  87.     {
  88.         return $this->image;
  89.     }
  90.     /**
  91.      * @param string|null $image
  92.      */
  93.     public function setImage(?string $image): void
  94.     {
  95.         $this->image $image;
  96.     }
  97.     /**
  98.      * @return string|null
  99.      */
  100.     public function getMetaTitle(): ?string
  101.     {
  102.         return $this->metaTitle;
  103.     }
  104.     /**
  105.      * @param string|null $metaTitle
  106.      */
  107.     public function setMetaTitle(?string $metaTitle): void
  108.     {
  109.         $this->metaTitle $metaTitle;
  110.     }
  111.     /**
  112.      * @return string|null
  113.      */
  114.     public function getMetaDescription(): ?string
  115.     {
  116.         return $this->metaDescription;
  117.     }
  118.     /**
  119.      * @param string|null $metaDescription
  120.      */
  121.     public function setMetaDescription(?string $metaDescription): void
  122.     {
  123.         $this->metaDescription $metaDescription;
  124.     }
  125.     /**
  126.      * @return string|null
  127.      */
  128.     public function getMetaImage(): ?string
  129.     {
  130.         return $this->metaImage;
  131.     }
  132.     /**
  133.      * @param string|null $metaImage
  134.      */
  135.     public function setMetaImage(?string $metaImage): void
  136.     {
  137.         $this->metaImage $metaImage;
  138.     }
  139.     /**
  140.      * @return mixed
  141.      */
  142.     public function getDescription(): mixed
  143.     {
  144.         return $this->description;
  145.     }
  146.     /**
  147.      * @param mixed $description
  148.      */
  149.     public function setDescription(mixed $description): void
  150.     {
  151.         $this->description $description;
  152.     }
  153.     /**
  154.      * @return string|null
  155.      */
  156.     public function getShortDescription(): ?string
  157.     {
  158.         return $this->shortDescription;
  159.     }
  160.     /**
  161.      * @param string|null $shortDescription
  162.      */
  163.     public function setShortDescription(?string $shortDescription): void
  164.     {
  165.         $this->shortDescription $shortDescription;
  166.     }
  167.     /**
  168.      * @return \DateTimeInterface|null
  169.      */
  170.     public function getCreatedAt(): ?\DateTimeInterface
  171.     {
  172.         return $this->createdAt;
  173.     }
  174.     /**
  175.      * @param \DateTimeInterface|null $createdAt
  176.      */
  177.     public function setCreatedAt(?\DateTimeInterface $createdAt): void
  178.     {
  179.         $this->createdAt $createdAt;
  180.     }
  181. }