<?php
namespace App\Entity;
use App\Repository\ServiceRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ServiceRepository::class)
*/
class Service
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $titre;
/**
* @ORM\Column(type="string", length=100000000)
*/
private $contenu;
/**
* @ORM\Column(type="string", length=255)
*/
private $image;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $altDescription;
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): self
{
$this->titre = $titre;
return $this;
}
public function getContenu(): ?string
{
return $this->contenu;
}
public function setContenu(string $contenu): self
{
$this->contenu = $contenu;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getAltDescription(): ?string
{
return $this->altDescription;
}
public function setAltDescription(string $altDescription): self
{
$this->altDescription = $altDescription;
return $this;
}
public function getDisplayContent(){
$pattern = '/h1/i';
$replacement = 'h2';
$contenu = preg_replace($pattern, $replacement, $this->contenu);
$pattern = '/<figure.*?>.*?<\/figure>/i';
$replacement = '';
$contenu = preg_replace($pattern, $replacement, $contenu);
return $contenu;
}
}