src/Entity/Service.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ServiceRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass=ServiceRepository::class)
  7. */
  8. class Service
  9. {
  10. /**
  11. * @ORM\Id
  12. * @ORM\GeneratedValue
  13. * @ORM\Column(type="integer")
  14. */
  15. private $id;
  16. /**
  17. * @ORM\Column(type="string", length=255)
  18. */
  19. private $titre;
  20. /**
  21. * @ORM\Column(type="string", length=100000000)
  22. */
  23. private $contenu;
  24. /**
  25. * @ORM\Column(type="string", length=255)
  26. */
  27. private $image;
  28. /**
  29. * @ORM\Column(type="string", length=255, nullable=true)
  30. */
  31. private $altDescription;
  32. public function getId(): ?int
  33. {
  34. return $this->id;
  35. }
  36. public function getTitre(): ?string
  37. {
  38. return $this->titre;
  39. }
  40. public function setTitre(string $titre): self
  41. {
  42. $this->titre = $titre;
  43. return $this;
  44. }
  45. public function getContenu(): ?string
  46. {
  47. return $this->contenu;
  48. }
  49. public function setContenu(string $contenu): self
  50. {
  51. $this->contenu = $contenu;
  52. return $this;
  53. }
  54. public function getImage(): ?string
  55. {
  56. return $this->image;
  57. }
  58. public function setImage(?string $image): self
  59. {
  60. $this->image = $image;
  61. return $this;
  62. }
  63. public function getAltDescription(): ?string
  64. {
  65. return $this->altDescription;
  66. }
  67. public function setAltDescription(string $altDescription): self
  68. {
  69. $this->altDescription = $altDescription;
  70. return $this;
  71. }
  72. public function getDisplayContent(){
  73. $pattern = '/h1/i';
  74. $replacement = 'h2';
  75. $contenu = preg_replace($pattern, $replacement, $this->contenu);
  76. $pattern = '/<figure.*?>.*?<\/figure>/i';
  77. $replacement = '';
  78. $contenu = preg_replace($pattern, $replacement, $contenu);
  79. return $contenu;
  80. }
  81. }