src/Entity/Actualite.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActualiteRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Timestampable\Traits\TimestampableEntity;
  7. use Symfony\Component\String\Slugger\AsciiSlugger;
  8. #[ORM\Entity(repositoryClassActualiteRepository::class)]
  9. class Actualite
  10. {
  11.     use TimestampableEntity;
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  17.     private ?\DateTimeInterface $date null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $titre null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $slug null;
  22.     #[ORM\Column(typeTypes::TEXT)]
  23.     private ?string $contenu null;
  24.     #[ORM\Column(typeTypes::TEXT)]
  25.     private ?string $contenuBrut null;
  26.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  27.     private ?string $keywords null;
  28.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  29.     private ?string $description null;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $banniere null;
  32.     #[ORM\Column]
  33.     private ?bool $actif null;
  34.     #[ORM\ManyToOne(cascade: ['persist'], fetch"EAGER"inversedBy'actualites')]
  35.     private ?Categorie $categorie null;
  36.     public function init()
  37.     {
  38.         preg_match'#<img .* src="(.*)".*>#isU'$this->contenu$matches );
  39.         if(isset($matches[1])) {
  40.             $this->setImgSrc($matches[1]);
  41.         } else {
  42.             $this->setImgSrc('/front/images/blog-1.jpeg');
  43.         }
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getDate(): ?\DateTimeInterface
  50.     {
  51.         return $this->date;
  52.     }
  53.     public function setDate(?\DateTimeInterface $date): self
  54.     {
  55.         $this->date $date;
  56.         return $this;
  57.     }
  58.     public function getTitre(): ?string
  59.     {
  60.         return $this->titre;
  61.     }
  62.     public function setTitre(string $titre): self
  63.     {
  64.         $this->titre $titre;
  65.         return $this;
  66.     }
  67.     public function getSlug(): ?string
  68.     {
  69.         return $this->slug;
  70.     }
  71.     public function setSlug(string $slug null): self
  72.     {
  73.         if ($slug) {
  74.             $this->slug $slug;
  75.         } else {
  76.             $slug = new AsciiSlugger();
  77.             $this->slug strtolower($slug->slug($this->titre).'.html');
  78.         }
  79.         return $this;
  80.     }
  81.     public function getContenu(): ?string
  82.     {
  83.         return $this->contenu;
  84.     }
  85.     public function setContenu(string $contenu): self
  86.     {
  87.         $this->contenu $contenu;
  88.         return $this;
  89.     }
  90.     public function getContenuBrut(): ?string
  91.     {
  92.         return $this->contenuBrut;
  93.     }
  94.     public function setContenuBrut(string $contenuBrut null): self
  95.     {
  96.         if ($contenuBrut) {
  97.             $this->contenuBrut $contenuBrut;
  98.         } else {
  99.             $this->contenuBrut strip_tags($this->contenu);
  100.         }
  101.         return $this;
  102.     }
  103.     public function getKeywords(): ?string
  104.     {
  105.         return $this->keywords;
  106.     }
  107.     public function setKeywords(?string $keywords): self
  108.     {
  109.         $this->keywords $keywords;
  110.         return $this;
  111.     }
  112.     public function getDescription(): ?string
  113.     {
  114.         return $this->description;
  115.     }
  116.     public function setDescription(?string $description): self
  117.     {
  118.         $this->description $description;
  119.         return $this;
  120.     }
  121.     public function isActif(): ?bool
  122.     {
  123.         return $this->actif;
  124.     }
  125.     public function setActif(bool $actif): self
  126.     {
  127.         $this->actif $actif;
  128.         return $this;
  129.     }
  130.     public function getBanniere(): ?string
  131.     {
  132.         return $this->banniere;
  133.     }
  134.     public function setBanniere(?string $banniere): self
  135.     {
  136.         $this->banniere $banniere;
  137.         return $this;
  138.     }
  139.     public function setImgSrc(?string $imgSrc): self
  140.     {
  141.         $this->imgSrc $imgSrc;
  142.         return $this;
  143.     }
  144.     public function getCategorie(): ?Categorie
  145.     {
  146.         return $this->categorie;
  147.     }
  148.     public function setCategorie(?Categorie $categorie): self
  149.     {
  150.         $this->categorie $categorie;
  151.         return $this;
  152.     }
  153. }