<?phpnamespace App\Entity\Fiches;use Doctrine\DBAL\Types\Types;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Validator\Constraints as Assert;use Doctrine\ORM\Mapping as ORM;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Symfony\Component\HttpFoundation\File\File;use Symfony\Component\HttpFoundation\File\UploadedFile;use Vich\UploaderBundle\Entity\File as EmbeddedFile;use App\Repository\Fiches\CategoriesRepository;/** * Categories * * @ORM\Table("fiches_categories") * @ORM\Entity(repositoryClass=CategoriesRepository::class) * @ORM\HasLifecycleCallbacks() * @Vich\Uploadable */class Categories{ /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var string * * @ORM\Column(name="created_at", type="datetime", nullable=true, options={"comment":"Date de création"}) */ private $createdAt; /** * @var string * * @ORM\Column(name="updated_at", type="datetime", nullable=true, options={"comment":"Date de mise à jour"}) */ private $updatedAt; /** * @var string * * @ORM\Column(name="title", type="string", length=500, nullable=true) */ private $title; /** * @var string * * @ORM\Column(name="slug", type="string", length=255, nullable=true) */ private $slug; /** * @var string * * @ORM\Column(name="short_title", type="string", length=255, nullable=true) */ private $shortTitle; /** * @var string * * @ORM\Column(name="description", type="text", nullable=true) */ private $description; /** * @var string * * @ORM\Column(name="short_description", type="text", nullable=true) */ private $shortDescription; /** * @var string * * @ORM\Column(name="robots", type="string", length=255, nullable=true) */ private $robots; /** * NOTE: This is not a mapped field of entity metadata, just a simple property. * * @Vich\UploadableField(mapping="pages_files", fileNameProperty="image.name", size="image.size", mimeType="image.mimeType", originalName="image.originalName", dimensions="image.dimensions") * * @var File|null */ private $imageFile; /** * @ORM\Embedded(class="Vich\UploaderBundle\Entity\File") * * @var EmbeddedFile */ private $image; /** * @var string * * @ORM\Column(name="canonical", type="text", nullable=true) */ private $canonical; /** * @var string * * @ORM\Column(name="author", type="string", length=155, nullable=true) */ private $author; public function __construct() { $this->image = new \Vich\UploaderBundle\Entity\File(); } /** * @ORM\PrePersist */ public function setCreatedAtValue(): void { $this->setCreatedAt(new \DateTime("now")); $this->setUpdatedAt(new \DateTime("now")); } /** * @ORM\PreUpdate */ public function setUpdatedAtValue(): void { $this->setUpdatedAt(new \DateTime("now")); } public function __toString() { return (string)$this->title; } /** * If manually uploading a file (i.e. not using Symfony Form) ensure an instance * of 'UploadedFile' is injected into this setter to trigger the update. If this * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter * must be able to accept an instance of 'File' as the bundle will inject one here * during Doctrine hydration. * * @param File|UploadedFile|null $imageFile */ public function setImageFile(?File $imageFile = null) { $this->imageFile = $imageFile; if (null !== $imageFile) { // It is required that at least one field changes if you are using doctrine // otherwise the event listeners won't be called and the file is lost $this->setUpdatedAt(new \DateTime("now")); } } public function getImageFile(): ?File { return $this->imageFile; } public function setImage(EmbeddedFile $image): void { $this->image = $image; } public function getImage(): ?EmbeddedFile { return $this->image; } 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 getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function getTitle(): ?string { return $this->title; } public function setTitle(?string $title): self { $this->title = $title; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(?string $slug): self { $this->slug = $slug; return $this; } public function getRobots(): ?string { return $this->robots; } public function setRobots(?string $robots): self { $this->robots = $robots; return $this; } public function getCanonical(): ?string { return $this->canonical; } public function setCanonical(?string $canonical): self { $this->canonical = $canonical; return $this; } public function getAuthor(): ?string { return $this->author; } public function setAuthor(?string $author): self { $this->author = $author; return $this; } public function getShortTitle(): ?string { return $this->shortTitle; } public function setShortTitle(?string $shortTitle): self { $this->shortTitle = $shortTitle; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getShortDescription(): ?string { return $this->shortDescription; } public function setShortDescription(?string $shortDescription): self { $this->shortDescription = $shortDescription; return $this; }}