src/Entity/Blog.php line 19

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\BlogRepository;
  4.     use App\Traits\DateTrait;
  5.     use Cocur\Slugify\Slugify;
  6.     use Doctrine\ORM\Mapping as ORM;
  7.     use JMS\Serializer\Annotation as Serializer;
  8.     use JMS\Serializer\Annotation\Expose;
  9.     use JMS\Serializer\Annotation\Groups;
  10.     /**
  11.      * @ORM\Entity(repositoryClass=BlogRepository::class)
  12.      *
  13.      * @ORM\HasLifecycleCallbacks()
  14.      * @Serializer\ExclusionPolicy("ALL")
  15.      */
  16.     class Blog
  17.     {
  18.         /**
  19.          * @ORM\Id
  20.          * @ORM\GeneratedValue
  21.          * @ORM\Column(type="integer")
  22.          *
  23.          * @Expose
  24.          * @Groups({"blog"})
  25.          *
  26.          */
  27.         private $id;
  28.         /**
  29.          * @ORM\Column(type="string", length=255)
  30.          *
  31.          * @Expose
  32.          * @Groups({"blog"})
  33.          */
  34.         private $title;
  35.         /**
  36.          * @ORM\Column(type="string", length=255)
  37.          */
  38.         private $slug;
  39.         /**
  40.          * @ORM\Column(type="text")
  41.          */
  42.         private $body;
  43.         /**
  44.          * @ORM\Column(type="boolean", options={"default":false})
  45.          *
  46.          * @Expose
  47.          * @Groups({"blog"})
  48.          */
  49.         private $published FALSE;
  50.         use DateTrait;
  51.         /*
  52.          * ============================================================================================
  53.          * =============================== FONCTIONS CUSTOM ===========================================
  54.          * ============================================================================================
  55.          */
  56.         /**
  57.          * @ORM\PrePersist()
  58.          * @ORM\PreUpdate()
  59.          */
  60.         public function prePersist()
  61.         {
  62.             $slugifier  = new Slugify();
  63.             $this->slug $slugifier->slugify$this->title );
  64.         }
  65.         /*
  66.          * ============================================================================================
  67.          * ============================== FIN FONCTIONS CUSTOM ========================================
  68.          * ============================================================================================
  69.          */
  70.         public function getId(): ?int
  71.         {
  72.             return $this->id;
  73.         }
  74.         public function getTitle(): ?string
  75.         {
  76.             return $this->title;
  77.         }
  78.         public function setTitlestring $title ): self
  79.         {
  80.             $this->title $title;
  81.             return $this;
  82.         }
  83.         public function getSlug(): ?string
  84.         {
  85.             return $this->slug;
  86.         }
  87.         public function setSlugstring $slug ): self
  88.         {
  89.             $this->slug $slug;
  90.             return $this;
  91.         }
  92.         public function getBody(): ?string
  93.         {
  94.             return $this->body;
  95.         }
  96.         public function setBodystring $body ): self
  97.         {
  98.             $this->body $body;
  99.             return $this;
  100.         }
  101.         public function getPublished(): ?bool
  102.         {
  103.             return $this->published;
  104.         }
  105.         public function setPublishedbool $published ): self
  106.         {
  107.             $this->published $published;
  108.             return $this;
  109.         }
  110.     }