<?php namespace App\Entity; use App\Repository\BlogRepository; use App\Traits\DateTrait; use Cocur\Slugify\Slugify; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; use JMS\Serializer\Annotation\Expose; use JMS\Serializer\Annotation\Groups; /** * @ORM\Entity(repositoryClass=BlogRepository::class) * * @ORM\HasLifecycleCallbacks() * @Serializer\ExclusionPolicy("ALL") */ class Blog { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") * * @Expose * @Groups({"blog"}) * */ private $id; /** * @ORM\Column(type="string", length=255) * * @Expose * @Groups({"blog"}) */ private $title; /** * @ORM\Column(type="string", length=255) */ private $slug; /** * @ORM\Column(type="text") */ private $body; /** * @ORM\Column(type="boolean", options={"default":false}) * * @Expose * @Groups({"blog"}) */ private $published = FALSE; use DateTrait; /* * ============================================================================================ * =============================== FONCTIONS CUSTOM =========================================== * ============================================================================================ */ /** * @ORM\PrePersist() * @ORM\PreUpdate() */ public function prePersist() { $slugifier = new Slugify(); $this->slug = $slugifier->slugify( $this->title ); } /* * ============================================================================================ * ============================== FIN FONCTIONS CUSTOM ======================================== * ============================================================================================ */ public function getId(): ?int { return $this->id; } public function getTitle(): ?string { return $this->title; } public function setTitle( string $title ): self { $this->title = $title; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug( string $slug ): self { $this->slug = $slug; return $this; } public function getBody(): ?string { return $this->body; } public function setBody( string $body ): self { $this->body = $body; return $this; } public function getPublished(): ?bool { return $this->published; } public function setPublished( bool $published ): self { $this->published = $published; return $this; } }