<?php
namespace App\Entity;
use App\Repository\SubSubCategoryRepository;
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=SubSubCategoryRepository::class)
*/
class SubSubCategory 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=SubCategory::class, inversedBy="subSubCategories")
*/
private $subCategory;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="subSubCategory")
*/
private $products;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Vich\UploadableField(mapping="subSubCategoryIcon", fileNameProperty="subSubCategoryIconFileName", size="subSubCategoryIconFileSize")
* @Assert\File(
* maxSize = "1200k"
* )
*
* @var File
*/
private $subSubCategoryIconFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $subSubCategoryIconFileName;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Vich\UploadableField(mapping="subSubCategoryBg", fileNameProperty="subSubCategoryBgFileName", size="subSubCategoryBgFileSize")
* @Assert\Expression("this.getSubSubCategoryBgFile() or this.getSubSubCategoryBgFileName()", message = "Veuillez sélectionner un fichier")
* @Assert\File(
* maxSize = "1200k"
* )
*
* @var File
*/
private $subSubCategoryBgFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $subSubCategoryBgFileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var integer
*/
private $subSubCategoryBgFileSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $subSubCategoryBgFileUpdatedAt;
/**
* 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 setSubSubCategoryBgFile(File $image = null) {
$this->subSubCategoryBgFile = $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->subSubCategoryBgFileUpdatedAt = new \DateTimeImmutable();
}
} public function getSubSubCategoryBgFile() {
return $this->subSubCategoryBgFile;
}
public function getSubSubCategoryBgFileName(): ?string
{
return $this->subSubCategoryBgFileName;
}
public function setSubSubCategoryBgFileName(?string $subSubCategoryBgFileName): self
{
$this->subSubCategoryBgFileName = $subSubCategoryBgFileName;
return $this;
}
public function getSubSubCategoryBgFileSize(): ?int
{
return $this->subSubCategoryBgFileSize;
}
public function setSubSubCategoryBgFileSize(?int $subSubCategoryBgFileSize): self
{
$this->subSubCategoryBgFileSize = $subSubCategoryBgFileSize;
return $this;
}
public function getSubSubCategoryBgFileUpdatedAt(): ?\DateTimeInterface
{
return $this->subSubCategoryBgFileUpdatedAt;
}
public function setSubSubCategoryBgFileUpdatedAt(?\DateTimeInterface $subSubCategoryBgFileUpdatedAt): self
{
$this->subSubCategoryBgFileUpdatedAt = $subSubCategoryBgFileUpdatedAt;
return $this;
}
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var integer
*/
private $subSubCategoryIconFileSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $subSubCategoryIconFileUpdatedAt;
/**
* 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 setSubSubCategoryIconFile(File $image = null) {
$this->subSubCategoryIconFile = $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->subSubCategoryIconFileUpdatedAt = new \DateTimeImmutable();
}
} public function getSubSubCategoryIconFile() {
return $this->subSubCategoryIconFile;
}
public function getSubSubCategoryIconFileName(): ?string
{
return $this->subSubCategoryIconFileName;
}
public function setSubSubCategoryIconFileName(?string $subSubCategoryIconFileName): self
{
$this->subSubCategoryIconFileName = $subSubCategoryIconFileName;
return $this;
}
public function getSubSubCategoryIconFileSize(): ?int
{
return $this->subSubCategoryIconFileSize;
}
public function setSubSubCategoryIconFileSize(?int $subSubCategoryIconFileSize): self
{
$this->subSubCategoryIconFileSize = $subSubCategoryIconFileSize;
return $this;
}
public function getSubSubCategoryIconFileUpdatedAt(): ?\DateTimeInterface
{
return $this->subSubCategoryIconFileUpdatedAt;
}
public function setSubSubCategoryIconFileUpdatedAt(?\DateTimeInterface $subSubCategoryIconFileUpdatedAt): self
{
$this->subSubCategoryIconFileUpdatedAt = $subSubCategoryIconFileUpdatedAt;
return $this;
}
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
* @Vich\UploadableField(mapping="subSubCategory", fileNameProperty="subSubCategoryFileName", size="subSubCategoryFileSize")
* @Assert\File(
* maxSize = "1200k"
* )
*
* @var File
*/
private $subSubCategoryFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $subSubCategoryFileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var integer
*/
private $subSubCategoryFileSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $subSubCategoryFileUpdatedAt;
/**
* @Gedmo\SortablePosition()
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
/**
* @ORM\OneToMany(targetEntity=SubSubSubCategory::class, mappedBy="subSubCategory")
*/
private $subSubSubCategories;
/**
* @ORM\OneToMany(targetEntity=ApplicationProduct::class, mappedBy="subSubCategory")
*/
private $applicationProducts;
/**
* 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 setSubSubCategoryFile(File $image = null)
{
$this->subSubCategoryFile = $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->subSubCategoryFileUpdatedAt = new \DateTimeImmutable();
}
}
public function getSubSubCategoryFile()
{
return $this->subSubCategoryFile;
}
public function getSubSubCategoryFileName(): ?string
{
return $this->subSubCategoryFileName;
}
public function setSubSubCategoryFileName(?string $subSubCategoryFileName): self
{
$this->subSubCategoryFileName = $subSubCategoryFileName;
return $this;
}
public function getSubSubCategoryFileSize(): ?int
{
return $this->subSubCategoryFileSize;
}
public function setSubSubCategoryFileSize(?int $subSubCategoryFileSize): self
{
$this->subSubCategoryFileSize = $subSubCategoryFileSize;
return $this;
}
public function getSubSubCategoryFileUpdatedAt(): ?\DateTimeInterface
{
return $this->subSubCategoryFileUpdatedAt;
}
public function setSubSubCategoryFileUpdatedAt(?\DateTimeInterface $subSubCategoryFileUpdatedAt): self
{
$this->subSubCategoryFileUpdatedAt = $subSubCategoryFileUpdatedAt;
return $this;
}
public function __construct()
{
$this->products = new ArrayCollection();
$this->subSubSubCategories = new ArrayCollection();
$this->applicationProducts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getSubCategory(): ?SubCategory
{
return $this->subCategory;
}
public function setSubCategory(?SubCategory $subCategory): self
{
$this->subCategory = $subCategory;
return $this;
}
public function setParent(?SubCategory $category): self
{
return $this->setSubCategory($category);
}
public function getParent(): ?SubCategory
{
return $this->subCategory;
}
/**
* @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->setSubSubCategory($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->getSubSubCategory() === $this) {
$product->setSubSubCategory(null);
}
}
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
/**
* @return Collection<int, SubSubSubCategory>
*/
public function getSubSubSubCategories(): Collection
{
return $this->subSubSubCategories;
}
public function addSubSubSubCategory(SubSubSubCategory $subSubSubCategory): self
{
if (!$this->subSubSubCategories->contains($subSubSubCategory)) {
$this->subSubSubCategories[] = $subSubSubCategory;
$subSubSubCategory->setSubSubCategory($this);
}
return $this;
}
public function removeSubSubSubCategory(SubSubSubCategory $subSubSubCategory): self
{
if ($this->subSubSubCategories->removeElement($subSubSubCategory)) {
// set the owning side to null (unless already changed)
if ($subSubSubCategory->getSubSubCategory() === $this) {
$subSubSubCategory->setSubSubCategory(null);
}
}
return $this;
}
public function findChild($name, $locale = 'fr') : ?SubSubSubCategory
{
foreach ($this->subSubSubCategories as $child) {
if ($child->getTitle() === $name) {
return $child;
}
}
return null;
}
public function addChild(SubSubSubCategory $child): self
{
return $this->addSubSubSubCategory($child);
}
/**
* @return Collection<int, ApplicationProduct>
*/
public function getApplicationProducts(): Collection
{
return $this->applicationProducts;
}
public function addApplicationProduct(ApplicationProduct $applicationProduct): self
{
if (!$this->applicationProducts->contains($applicationProduct)) {
$this->applicationProducts[] = $applicationProduct;
$applicationProduct->setSubSubCategory($this);
}
return $this;
}
public function removeApplicationProduct(ApplicationProduct $applicationProduct): self
{
if ($this->applicationProducts->removeElement($applicationProduct)) {
if ($applicationProduct->getSubSubCategory() === $this) {
$applicationProduct->setSubSubCategory(null);
}
}
return $this;
}
}