Bonjour à tous,
Dans le cadre d'un projet Symfony, je suis en train d'installer EasyAdminBundle.
J'ai une entité, Page, composée comme ceci :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| <?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\PageRepository")
*/
class Page
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
*/
private $editedAt;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $user;
/**
* @ORM\Column(type="boolean")
*/
private $isPublished;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* Page constructor.
* @param $slug
*/
public function __construct($title)
{
$this->slug = $title;
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getEditedAt(): ?\DateTimeInterface
{
return $this->editedAt;
}
public function setEditedAt(\DateTimeInterface $editedAt): self
{
$this->editedAt = $editedAt;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getUser(): ?string
{
return $this->user;
}
public function setUser(?string $user): self
{
$this->user = $user;
return $this;
}
public function getIsPublished(): ?bool
{
return $this->isPublished;
}
public function setIsPublished(bool $isPublished): self
{
$this->isPublished = $isPublished;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
} |
Lorsque je créé une page via EasyAdminBundle, j'ai ce message d'erreur :
An exception has been thrown during the rendering of a template ("Warning: strip_tags() expects parameter 1 to be string, object given").
J'ai cru comprendre qu'il fallait que j'utilise la méthode __toString() pour solutionner ce problème. Mais je ne comprends pas comment ?
Si vous avez une idée, je suis preneuse 
Merci d'avance !
Vanessa
Partager