<?phpnamespace App\Entity;use App\Repository\ActualiteRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Gedmo\Timestampable\Traits\TimestampableEntity;use Symfony\Component\String\Slugger\AsciiSlugger;#[ORM\Entity(repositoryClass: ActualiteRepository::class)]class Actualite{ use TimestampableEntity; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)] private ?\DateTimeInterface $date = null; #[ORM\Column(length: 255)] private ?string $titre = null; #[ORM\Column(length: 255)] private ?string $slug = null; #[ORM\Column(type: Types::TEXT)] private ?string $contenu = null; #[ORM\Column(type: Types::TEXT)] private ?string $contenuBrut = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $keywords = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $description = null; #[ORM\Column(length: 255, nullable: true)] private ?string $banniere = null; #[ORM\Column] private ?bool $actif = null; #[ORM\ManyToOne(cascade: ['persist'], fetch: "EAGER", inversedBy: 'actualites')] private ?Categorie $categorie = null; public function init() { preg_match( '#<img .* src="(.*)".*>#isU', $this->contenu, $matches ); if(isset($matches[1])) { $this->setImgSrc($matches[1]); } else { $this->setImgSrc('/front/images/blog-1.jpeg'); } } public function getId(): ?int { return $this->id; } public function getDate(): ?\DateTimeInterface { return $this->date; } public function setDate(?\DateTimeInterface $date): self { $this->date = $date; return $this; } public function getTitre(): ?string { return $this->titre; } public function setTitre(string $titre): self { $this->titre = $titre; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug = null): self { if ($slug) { $this->slug = $slug; } else { $slug = new AsciiSlugger(); $this->slug = strtolower($slug->slug($this->titre).'.html'); } return $this; } public function getContenu(): ?string { return $this->contenu; } public function setContenu(string $contenu): self { $this->contenu = $contenu; return $this; } public function getContenuBrut(): ?string { return $this->contenuBrut; } public function setContenuBrut(string $contenuBrut = null): self { if ($contenuBrut) { $this->contenuBrut = $contenuBrut; } else { $this->contenuBrut = strip_tags($this->contenu); } return $this; } public function getKeywords(): ?string { return $this->keywords; } public function setKeywords(?string $keywords): self { $this->keywords = $keywords; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function isActif(): ?bool { return $this->actif; } public function setActif(bool $actif): self { $this->actif = $actif; return $this; } public function getBanniere(): ?string { return $this->banniere; } public function setBanniere(?string $banniere): self { $this->banniere = $banniere; return $this; } public function setImgSrc(?string $imgSrc): self { $this->imgSrc = $imgSrc; return $this; } public function getCategorie(): ?Categorie { return $this->categorie; } public function setCategorie(?Categorie $categorie): self { $this->categorie = $categorie; return $this; }}