Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.humitest.fr
/
htdocs
/
src
/
Entity
/
/srv/data/web/vhosts/www.humitest.fr/htdocs/src/Entity/Category.php
<?php namespace App\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\File; use Vich\UploaderBundle\Mapping\Annotation as Vich; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\HttpFoundation\File\UploadedFile; /** * @ORM\Entity(repositoryClass="App\Repository\CategoryRepository") * @Vich\Uploadable */ class Category { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * NOTE: This is not a mapped field of entity metadata, just a simple property. * * @Vich\UploadableField(mapping="category_images", fileNameProperty="imageName") * @Assert\Image( * maxWidth = 1000, * minWidth = 400, * ) * @Assert\File(mimeTypes = {"image/jpg", "image/jpeg"}) * * @var File */ private $imageFile; /** * @ORM\Column(type="string", length=255, nullable=true) * * @var string */ private $imageName; /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\Column(type="datetime") */ private $updatedAt; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\Column(type="text") */ private $content; /** * @ORM\OneToMany(targetEntity="App\Entity\Product", mappedBy="category") */ private $products; public function __construct() { $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); $this->products = new ArrayCollection(); } public function __toString() { return $this->getName(); } public function getId(): ?int { return $this->id; } public function getImageName(): ?string { return $this->imageName; } public function setImageName(?string $imageName): void { $this->imageName = $imageName; } /** * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $imageFile * */ public function setimageFile(?File $imageFile = null): void { $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->updatedAt = new \DateTimeImmutable(); } } public function getImageFile(): ?File { return $this->imageFile; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getContent(): ?string { return $this->content; } public function setContent(string $content): self { $this->content = $content; return $this; } /** * @return Collection|Product[] */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): self { if (!$this->products->contains($product)) { $this->products[] = $product; $product->setCategory($this); } return $this; } public function removeProduct(Product $product): self { if ($this->products->contains($product)) { $this->products->removeElement($product); // set the owning side to null (unless already changed) if ($product->getCategory() === $this) { $product->setCategory(null); } } return $this; } }