<?php
namespace App\Entity;
use App\Repository\SubSubSubCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Vich\Uploadable
* @ORM\Entity(repositoryClass=SubSubSubCategoryRepository::class)
*/
class SubSubSubCategory implements TranslatableInterface
{
use TranslatableTrait;
public function __call($method, $arguments)
{
return $this->proxyCurrentLocaleTranslation($method, $arguments);
}
public function __get($name)
{
$method = 'get' . ucfirst($name);
$arguments = [];
return $this->proxyCurrentLocaleTranslation($method, $arguments);
}
public function __toString()
{
return "#" . $this->id . " " . $this->getTitle();
}
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @Gedmo\SortableGroup()
* @Assert\NotBlank()
* @ORM\ManyToOne(targetEntity=SubSubCategory::class, inversedBy="subSubSubCategories")
*/
private $subSubCategory;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="subSubSubCategory")
*/
private $products;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Vich\UploadableField(mapping="subSubSubCategoryIcon", fileNameProperty="subSubSubCategoryIconFileName", size="subSubSubCategoryIconFileSize")
* @Assert\File(
* maxSize = "1200k"
* )
*
* @var File
*/
private $subSubSubCategoryIconFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $subSubSubCategoryIconFileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var integer
*/
private $subSubSubCategoryIconFileSize;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Vich\UploadableField(mapping="subSubSubCategoryBg", fileNameProperty="subSubSubCategoryBgFileName", size="subSubSubCategoryBgFileSize")
* @Assert\Expression("this.getSubSubSubCategoryBgFile() or this.getSubSubSubCategoryBgFileName()", message = "Veuillez sélectionner un fichier")
* @Assert\File(
* maxSize = "1200k"
* )
*
* @var File
*/
private $subSubSubCategoryBgFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $subSubSubCategoryBgFileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var integer
*/
private $subSubSubCategoryBgFileSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $subSubSubCategoryBgFileUpdatedAt;
/**
* 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|\Symfony\Component\HttpFoundation\File\UploadedFile $image
*/
public function setSubSubSubCategoryBgFile(File $image = null)
{
$this->subSubSubCategoryBgFile = $image;
if (null !== $image) {
// 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->subSubSubCategoryBgFileUpdatedAt = new \DateTimeImmutable();
}
}
public function getSubSubSubCategoryBgFile()
{
return $this->subSubSubCategoryBgFile;
}
public function getSubSubSubCategoryBgFileName(): ?string
{
return $this->subSubSubCategoryBgFileName;
}
public function setSubSubSubCategoryBgFileName(?string $subSubSubCategoryBgFileName): self
{
$this->subSubSubCategoryBgFileName = $subSubSubCategoryBgFileName;
return $this;
}
public function getSubSubSubCategoryBgFileSize(): ?int
{
return $this->subSubSubCategoryBgFileSize;
}
public function setSubSubSubCategoryBgFileSize(?int $subSubSubCategoryBgFileSize): self
{
$this->subSubSubCategoryBgFileSize = $subSubSubCategoryBgFileSize;
return $this;
}
public function getSubSubSubCategoryBgFileUpdatedAt(): ?\DateTimeInterface
{
return $this->subSubSubCategoryBgFileUpdatedAt;
}
public function setSubSubSubCategoryBgFileUpdatedAt(?\DateTimeInterface $subSubSubCategoryBgFileUpdatedAt): self
{
$this->subSubSubCategoryBgFileUpdatedAt = $subSubSubCategoryBgFileUpdatedAt;
return $this;
}
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $subSubSubCategoryIconFileUpdatedAt;
/**
* 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|\Symfony\Component\HttpFoundation\File\UploadedFile $image
*/
public function setSubSubSubCategoryIconFile(File $image = null)
{
$this->subSubSubCategoryIconFile = $image;
if (null !== $image) {
// 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->subSubSubCategoryIconFileUpdatedAt = new \DateTimeImmutable();
}
}
public function getSubSubSubCategoryIconFile()
{
return $this->subSubSubCategoryIconFile;
}
public function getSubSubSubCategoryIconFileName(): ?string
{
return $this->subSubSubCategoryIconFileName;
}
public function setSubSubSubCategoryIconFileName(?string $subSubSubCategoryIconFileName): self
{
$this->subSubSubCategoryIconFileName = $subSubSubCategoryIconFileName;
return $this;
}
public function getSubSubSubCategoryIconFileSize(): ?int
{
return $this->subSubSubCategoryIconFileSize;
}
public function setSubSubSubCategoryIconFileSize(?int $subSubSubCategoryIconFileSize): self
{
$this->subSubSubCategoryIconFileSize = $subSubSubCategoryIconFileSize;
return $this;
}
public function getSubSubSubCategoryIconFileUpdatedAt(): ?\DateTimeInterface
{
return $this->subSubSubCategoryIconFileUpdatedAt;
}
public function setSubSubSubCategoryIconFileUpdatedAt(?\DateTimeInterface $subSubSubCategoryIconFileUpdatedAt): self
{
$this->subSubSubCategoryIconFileUpdatedAt = $subSubSubCategoryIconFileUpdatedAt;
return $this;
}
/**
* @Gedmo\SortablePosition()
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Vich\UploadableField(mapping="subSubSubCategory", fileNameProperty="subSubSubCategoryFileName", size="subSubSubCategoryFileSize")
* @Assert\File(
* maxSize = "1200k"
* )
*
* @var File
*/
private $subSubSubCategoryFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $subSubSubCategoryFileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var integer
*/
private $subSubSubCategoryFileSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $subSubSubCategoryFileUpdatedAt;
/**
* 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|\Symfony\Component\HttpFoundation\File\UploadedFile $image
*/
public function setSubSubSubCategoryFile(File $image = null)
{
$this->subSubSubCategoryFile = $image;
if (null !== $image) {
// 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->subSubSubCategoryFileUpdatedAt = new \DateTimeImmutable();
}
}
public function getSubSubSubCategoryFile()
{
return $this->subSubSubCategoryFile;
}
public function getSubSubSubCategoryFileName(): ?string
{
return $this->subSubSubCategoryFileName;
}
public function setSubSubSubCategoryFileName(?string $subSubSubCategoryFileName): self
{
$this->subSubSubCategoryFileName = $subSubSubCategoryFileName;
return $this;
}
public function getSubSubSubCategoryFileSize(): ?int
{
return $this->subSubSubCategoryFileSize;
}
public function setSubSubSubCategoryFileSize(?int $subSubSubCategoryFileSize): self
{
$this->subSubSubCategoryFileSize = $subSubSubCategoryFileSize;
return $this;
}
public function getSubSubSubCategoryFileUpdatedAt(): ?\DateTimeInterface
{
return $this->subSubSubCategoryFileUpdatedAt;
}
public function setSubSubSubCategoryFileUpdatedAt(?\DateTimeInterface $subSubSubCategoryFileUpdatedAt): self
{
$this->subSubSubCategoryFileUpdatedAt = $subSubSubCategoryFileUpdatedAt;
return $this;
}
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getSubSubCategory(): ?SubSubCategory
{
return $this->subSubCategory;
}
public function setSubSubCategory(?SubSubCategory $subSubCategory): self
{
$this->subSubCategory = $subSubCategory;
return $this;
}
public function setParent(?SubSubCategory $category): self
{
return $this->setSubSubCategory($category);
}
public function getParent(): ?SubSubCategory
{
return $this->subSubCategory;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setSubSubSubCategory($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getSubSubSubCategory() === $this) {
$product->setSubSubSubCategory(null);
}
}
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
}