src/Entity/SubSubSubCategory.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubSubSubCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * @Vich\Uploadable
  15.  * @ORM\Entity(repositoryClass=SubSubSubCategoryRepository::class)
  16.  */
  17. class SubSubSubCategory implements TranslatableInterface
  18. {
  19.     use TranslatableTrait;
  20.     public function __call($method$arguments)
  21.     {
  22.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  23.     }
  24.     public function __get($name)
  25.     {
  26.         $method 'get' ucfirst($name);
  27.         $arguments = [];
  28.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  29.     }
  30.     public function __toString()
  31.     {
  32.         return "#" $this->id " " $this->getTitle();
  33.     }
  34.     /**
  35.      * @ORM\Id
  36.      * @ORM\GeneratedValue
  37.      * @ORM\Column(type="integer")
  38.      */
  39.     private $id;
  40.     /**
  41.      * @Gedmo\SortableGroup()
  42.      * @Assert\NotBlank()
  43.      * @ORM\ManyToOne(targetEntity=SubSubCategory::class, inversedBy="subSubSubCategories")
  44.      */
  45.     private $subSubCategory;
  46.     /**
  47.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="subSubSubCategory")
  48.      */
  49.     private $products;
  50.     /**
  51.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  52.      * @Vich\UploadableField(mapping="subSubSubCategoryIcon", fileNameProperty="subSubSubCategoryIconFileName", size="subSubSubCategoryIconFileSize")
  53.      * @Assert\File(
  54.      *     maxSize = "1200k"
  55.      * )
  56.      *
  57.      * @var File
  58.      */
  59.     private $subSubSubCategoryIconFile;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      *
  63.      * @var string
  64.      */
  65.     private $subSubSubCategoryIconFileName;
  66.     /**
  67.      * @ORM\Column(type="integer", nullable=true)
  68.      *
  69.      * @var integer
  70.      */
  71.     private $subSubSubCategoryIconFileSize;
  72.     /**
  73.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  74.      * @Vich\UploadableField(mapping="subSubSubCategoryBg", fileNameProperty="subSubSubCategoryBgFileName", size="subSubSubCategoryBgFileSize")
  75.      * @Assert\Expression("this.getSubSubSubCategoryBgFile() or this.getSubSubSubCategoryBgFileName()", message = "Veuillez sélectionner un fichier")
  76.      * @Assert\File(
  77.      *     maxSize = "1200k"
  78.      * )
  79.      *
  80.      * @var File
  81.      */
  82.     private $subSubSubCategoryBgFile;
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      *
  86.      * @var string
  87.      */
  88.     private $subSubSubCategoryBgFileName;
  89.     /**
  90.      * @ORM\Column(type="integer", nullable=true)
  91.      *
  92.      * @var integer
  93.      */
  94.     private $subSubSubCategoryBgFileSize;
  95.     /**
  96.      * @ORM\Column(type="datetime", nullable=true)
  97.      *
  98.      * @var \DateTime
  99.      */
  100.     private $subSubSubCategoryBgFileUpdatedAt;
  101.     /**
  102.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  103.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  104.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  105.      * must be able to accept an instance of 'File' as the bundle will inject one here
  106.      * during Doctrine hydration.
  107.      *
  108.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  109.      */
  110.     public function setSubSubSubCategoryBgFile(File $image null)
  111.     {
  112.         $this->subSubSubCategoryBgFile $image;
  113.         if (null !== $image) {
  114.             // It is required that at least one field changes if you are using doctrine
  115.             // otherwise the event listeners won't be called and the file is lost
  116.             $this->subSubSubCategoryBgFileUpdatedAt = new \DateTimeImmutable();
  117.         }
  118.     }
  119.     public function getSubSubSubCategoryBgFile()
  120.     {
  121.         return $this->subSubSubCategoryBgFile;
  122.     }
  123.     public function getSubSubSubCategoryBgFileName(): ?string
  124.     {
  125.         return $this->subSubSubCategoryBgFileName;
  126.     }
  127.     public function setSubSubSubCategoryBgFileName(?string $subSubSubCategoryBgFileName): self
  128.     {
  129.         $this->subSubSubCategoryBgFileName $subSubSubCategoryBgFileName;
  130.         return $this;
  131.     }
  132.     public function getSubSubSubCategoryBgFileSize(): ?int
  133.     {
  134.         return $this->subSubSubCategoryBgFileSize;
  135.     }
  136.     public function setSubSubSubCategoryBgFileSize(?int $subSubSubCategoryBgFileSize): self
  137.     {
  138.         $this->subSubSubCategoryBgFileSize $subSubSubCategoryBgFileSize;
  139.         return $this;
  140.     }
  141.     public function getSubSubSubCategoryBgFileUpdatedAt(): ?\DateTimeInterface
  142.     {
  143.         return $this->subSubSubCategoryBgFileUpdatedAt;
  144.     }
  145.     public function setSubSubSubCategoryBgFileUpdatedAt(?\DateTimeInterface $subSubSubCategoryBgFileUpdatedAt): self
  146.     {
  147.         $this->subSubSubCategoryBgFileUpdatedAt $subSubSubCategoryBgFileUpdatedAt;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @ORM\Column(type="datetime", nullable=true)
  152.      *
  153.      * @var \DateTime
  154.      */
  155.     private $subSubSubCategoryIconFileUpdatedAt;
  156.     /**
  157.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  158.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  159.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  160.      * must be able to accept an instance of 'File' as the bundle will inject one here
  161.      * during Doctrine hydration.
  162.      *
  163.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  164.      */
  165.     public function setSubSubSubCategoryIconFile(File $image null)
  166.     {
  167.         $this->subSubSubCategoryIconFile $image;
  168.         if (null !== $image) {
  169.             // It is required that at least one field changes if you are using doctrine
  170.             // otherwise the event listeners won't be called and the file is lost
  171.             $this->subSubSubCategoryIconFileUpdatedAt = new \DateTimeImmutable();
  172.         }
  173.     }
  174.     public function getSubSubSubCategoryIconFile()
  175.     {
  176.         return $this->subSubSubCategoryIconFile;
  177.     }
  178.     public function getSubSubSubCategoryIconFileName(): ?string
  179.     {
  180.         return $this->subSubSubCategoryIconFileName;
  181.     }
  182.     public function setSubSubSubCategoryIconFileName(?string $subSubSubCategoryIconFileName): self
  183.     {
  184.         $this->subSubSubCategoryIconFileName $subSubSubCategoryIconFileName;
  185.         return $this;
  186.     }
  187.     public function getSubSubSubCategoryIconFileSize(): ?int
  188.     {
  189.         return $this->subSubSubCategoryIconFileSize;
  190.     }
  191.     public function setSubSubSubCategoryIconFileSize(?int $subSubSubCategoryIconFileSize): self
  192.     {
  193.         $this->subSubSubCategoryIconFileSize $subSubSubCategoryIconFileSize;
  194.         return $this;
  195.     }
  196.     public function getSubSubSubCategoryIconFileUpdatedAt(): ?\DateTimeInterface
  197.     {
  198.         return $this->subSubSubCategoryIconFileUpdatedAt;
  199.     }
  200.     public function setSubSubSubCategoryIconFileUpdatedAt(?\DateTimeInterface $subSubSubCategoryIconFileUpdatedAt): self
  201.     {
  202.         $this->subSubSubCategoryIconFileUpdatedAt $subSubSubCategoryIconFileUpdatedAt;
  203.         return $this;
  204.     }
  205.     /**
  206.      * @Gedmo\SortablePosition()
  207.      * @ORM\Column(type="integer", nullable=true)
  208.      */
  209.     private $position;
  210.     /**
  211.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  212.      * @Vich\UploadableField(mapping="subSubSubCategory", fileNameProperty="subSubSubCategoryFileName", size="subSubSubCategoryFileSize")
  213.      * @Assert\File(
  214.      *     maxSize = "1200k"
  215.      * )
  216.      *
  217.      * @var File
  218.      */
  219.     private $subSubSubCategoryFile;
  220.     /**
  221.      * @ORM\Column(type="string", length=255, nullable=true)
  222.      *
  223.      * @var string
  224.      */
  225.     private $subSubSubCategoryFileName;
  226.     /**
  227.      * @ORM\Column(type="integer", nullable=true)
  228.      *
  229.      * @var integer
  230.      */
  231.     private $subSubSubCategoryFileSize;
  232.     /**
  233.      * @ORM\Column(type="datetime", nullable=true)
  234.      *
  235.      * @var \DateTime
  236.      */
  237.     private $subSubSubCategoryFileUpdatedAt;
  238.     /**
  239.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  240.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  241.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  242.      * must be able to accept an instance of 'File' as the bundle will inject one here
  243.      * during Doctrine hydration.
  244.      *
  245.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  246.      */
  247.     public function setSubSubSubCategoryFile(File $image null)
  248.     {
  249.         $this->subSubSubCategoryFile $image;
  250.         if (null !== $image) {
  251.             // It is required that at least one field changes if you are using doctrine
  252.             // otherwise the event listeners won't be called and the file is lost
  253.             $this->subSubSubCategoryFileUpdatedAt = new \DateTimeImmutable();
  254.         }
  255.     }
  256.     public function getSubSubSubCategoryFile()
  257.     {
  258.         return $this->subSubSubCategoryFile;
  259.     }
  260.     public function getSubSubSubCategoryFileName(): ?string
  261.     {
  262.         return $this->subSubSubCategoryFileName;
  263.     }
  264.     public function setSubSubSubCategoryFileName(?string $subSubSubCategoryFileName): self
  265.     {
  266.         $this->subSubSubCategoryFileName $subSubSubCategoryFileName;
  267.         return $this;
  268.     }
  269.     public function getSubSubSubCategoryFileSize(): ?int
  270.     {
  271.         return $this->subSubSubCategoryFileSize;
  272.     }
  273.     public function setSubSubSubCategoryFileSize(?int $subSubSubCategoryFileSize): self
  274.     {
  275.         $this->subSubSubCategoryFileSize $subSubSubCategoryFileSize;
  276.         return $this;
  277.     }
  278.     public function getSubSubSubCategoryFileUpdatedAt(): ?\DateTimeInterface
  279.     {
  280.         return $this->subSubSubCategoryFileUpdatedAt;
  281.     }
  282.     public function setSubSubSubCategoryFileUpdatedAt(?\DateTimeInterface $subSubSubCategoryFileUpdatedAt): self
  283.     {
  284.         $this->subSubSubCategoryFileUpdatedAt $subSubSubCategoryFileUpdatedAt;
  285.         return $this;
  286.     }
  287.     public function __construct()
  288.     {
  289.         $this->products = new ArrayCollection();
  290.     }
  291.     public function getId(): ?int
  292.     {
  293.         return $this->id;
  294.     }
  295.     public function getSubSubCategory(): ?SubSubCategory
  296.     {
  297.         return $this->subSubCategory;
  298.     }
  299.     public function setSubSubCategory(?SubSubCategory $subSubCategory): self
  300.     {
  301.         $this->subSubCategory $subSubCategory;
  302.         return $this;
  303.     }
  304.     public function setParent(?SubSubCategory $category): self
  305.     {
  306.         return $this->setSubSubCategory($category);
  307.     }
  308.     public function getParent(): ?SubSubCategory
  309.     {
  310.         return $this->subSubCategory;
  311.     }
  312.     /**
  313.      * @return Collection<int, Product>
  314.      */
  315.     public function getProducts(): Collection
  316.     {
  317.         return $this->products;
  318.     }
  319.     public function addProduct(Product $product): self
  320.     {
  321.         if (!$this->products->contains($product)) {
  322.             $this->products[] = $product;
  323.             $product->setSubSubSubCategory($this);
  324.         }
  325.         return $this;
  326.     }
  327.     public function removeProduct(Product $product): self
  328.     {
  329.         if ($this->products->removeElement($product)) {
  330.             // set the owning side to null (unless already changed)
  331.             if ($product->getSubSubSubCategory() === $this) {
  332.                 $product->setSubSubSubCategory(null);
  333.             }
  334.         }
  335.         return $this;
  336.     }
  337.     public function getPosition(): ?int
  338.     {
  339.         return $this->position;
  340.     }
  341.     public function setPosition(?int $position): self
  342.     {
  343.         $this->position $position;
  344.         return $this;
  345.     }
  346. }