src/Entity/Produit/SousFamille.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Produit;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\SousFamilleRepository")
  12.  * @UniqueEntity("seoUrl")
  13.  * @Vich\Uploadable
  14.  */
  15. class SousFamille
  16. {
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue()
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $designation;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $designationCollectionFiltre;
  31.     /**
  32.      * @ORM\Column(type="string", length=255)
  33.      */
  34.     private $designationCollectionFiltreBis;
  35.     /**
  36.      * @ORM\ManyToMany(targetEntity="App\Entity\Produit\Produit", mappedBy="subFamille")
  37.      * @ORM\OrderBy({"placement" = "ASC"})
  38.      */
  39.     private $produits;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity="App\Entity\Produit\FamilleProduit", inversedBy="sousFamilles")
  42.      * @ORM\JoinColumn(nullable=false)
  43.      */
  44.     private $familleProduit;
  45.     /**
  46.      * @ORM\Column(type="string", length=255)
  47.      */
  48.     private $seoUrl;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $metaTitle;
  53.     /**
  54.      * @ORM\Column(type="text", nullable=true)
  55.      */
  56.     private $metaDescription;
  57.     /**
  58.      * @ORM\Column(type="text")
  59.      */
  60.     private $navbarText;
  61.     /**
  62.      * @ORM\Column(type="integer")
  63.      */
  64.     private $placement;
  65.     //--------------------------------------------------------- 
  66.     //                  VICHUPLOADER propriété START
  67.     //--------------------------------------------------------- 
  68.     /**
  69.      * @ORM\Column(type="text", nullable=true)
  70.      */
  71.     private $urlImage;
  72.     /**
  73.      * @Vich\UploadableField(mapping="sous_famille_produit_images", fileNameProperty="urlImage")
  74.      *  @Assert\File(
  75.      *     maxSize = "350k",
  76.      *     maxSizeMessage = "La taille maximale autorisée et de {{ limit }} {{ suffix }}, {{ name }} fait {{ size }} {{ suffix }}.",
  77.      *     mimeTypes = {"image/jpg", "image/jpeg", "image/png", "image/svg", "image/webp"},
  78.      *     mimeTypesMessage = "{{ name }} possède un format non pris en charge ({{ type }}), les formats autorisés sont : {{ types }}."
  79.      * )
  80.      * @var File
  81.      */
  82.     private $imageFile;
  83.     /**
  84.      * @ORM\Column(type="text", nullable=true)
  85.      */
  86.     private $urlImageEntete;
  87.     /**
  88.      * @Vich\UploadableField(mapping="sous_famille_produit_images", fileNameProperty="urlImageEntete")
  89.      *  @Assert\File(
  90.      *     maxSize = "350k",
  91.      *     maxSizeMessage = "La taille maximale autorisée et de {{ limit }} {{ suffix }}, {{ name }} fait {{ size }} {{ suffix }}.",
  92.      *     mimeTypes = {"image/jpg", "image/jpeg", "image/png", "image/svg", "image/webp"},
  93.      *     mimeTypesMessage = "{{ name }} possède un format non pris en charge ({{ type }}), les formats autorisés sont : {{ types }}."
  94.      * )
  95.      * @var File
  96.      */
  97.     private $imageFileEntete;
  98.     /**
  99.      * @ORM\Column(type="date", nullable=true)
  100.      */
  101.     private $date;
  102.     //--------------------------------------------------------- 
  103.     //                  VICHUPLOADER propriété END
  104.     //--------------------------------------------------------- 
  105.     /**
  106.      * @ORM\Column(type="text", nullable=true)
  107.      */
  108.     private $description;
  109.     /**
  110.      * @ORM\Column(type="text", nullable=true)
  111.      */
  112.     private $descriptionFin;
  113.     /**
  114.      * @ORM\Column(type="string", length=255, nullable=true)
  115.      */
  116.     private $configurateur;
  117.     /**
  118.      * @ORM\ManyToMany(targetEntity=SousFamilleType::class, mappedBy="subFamille")
  119.      */
  120.     private $sousFamilleTypes;
  121.     public function __construct()
  122.     {
  123.         $this->produits = new ArrayCollection();
  124.         $this->sousFamilleTypes = new ArrayCollection();
  125.     }
  126.     public function __toString()
  127.     {
  128.         return $this->getFamilleProduit()->getDesignation() . " : "$this->getDesignation();
  129.     }
  130.     
  131.     //--------------------------------------------------------- 
  132.     //                  VICHUPLOADER méthode START
  133.     //--------------------------------------------------------- 
  134.     public function setImageFile(File $urlImage null)
  135.     {
  136.         $this->imageFile $urlImage;
  137.         // VERY IMPORTANT:
  138.         // It is required that at least one field changes if you are using Doctrine,
  139.         // otherwise the event listeners won't be called and the file is lost
  140.         /*if ($urlImage) {
  141.             // if 'updatedAt' is not defined in your entity, use another property
  142.             $this->date = new \DateTime('now');
  143.         }*/
  144.     }
  145.     public function getImageFile()
  146.     {
  147.         return $this->imageFile;
  148.     }
  149.     public function getUrlImage(): ?string
  150.     {
  151.         return $this->urlImage;
  152.     }
  153.     public function setUrlImage(?string $urlImage): self
  154.     {
  155.         $this->urlImage $urlImage;
  156.         return $this;
  157.     }
  158.     public function getMetaTitle(): ?string
  159.     {
  160.         return $this->metaTitle;
  161.     }
  162.     public function setMetaTitle(?string $metaTitle): self
  163.     {
  164.         $this->metaTitle $metaTitle;
  165.         return $this;
  166.     }
  167.     public function getMetaDescription(): ?string
  168.     {
  169.         return $this->metaDescription;
  170.     }
  171.     public function setMetaDescription(?string $metaDescription): self
  172.     {
  173.         $this->metaDescription $metaDescription;
  174.         return $this;
  175.     }
  176.     public function setImageFileEntete(File $urlImageEntete null)
  177.     {
  178.         $this->imageFileEntete $urlImageEntete;
  179.         // VERY IMPORTANT:
  180.         // It is required that at least one field changes if you are using Doctrine,
  181.         // otherwise the event listeners won't be called and the file is lost
  182.         if ($urlImageEntete) {
  183.             // if 'updatedAt' is not defined in your entity, use another property
  184.             $this->date = new \DateTime('now');
  185.         }
  186.     }
  187.     public function getImageFileEntete()
  188.     {
  189.         return $this->imageFileEntete;
  190.     }
  191.     public function getUrlImageEntete(): ?string
  192.     {
  193.         return $this->urlImageEntete;
  194.     }
  195.     public function setUrlImageEntete(?string $urlImageEntete): self
  196.     {
  197.         $this->urlImageEntete $urlImageEntete;
  198.         return $this;
  199.     }
  200.     public function getDate(): ?\DateTimeInterface
  201.     {
  202.         return $this->date;
  203.     }
  204.     public function setDate(\DateTimeInterface $date): self
  205.     {
  206.         $this->date $date;
  207.         return $this;
  208.     }
  209.     //--------------------------------------------------------- 
  210.     //                  VICHUPLOADER méthode END
  211.     //--------------------------------------------------------- 
  212.     public function getId(): ?int
  213.     {
  214.         return $this->id;
  215.     }
  216.     public function getDesignation(): ?string
  217.     {
  218.         return $this->designation;
  219.     }
  220.     public function setDesignation(string $designation): self
  221.     {
  222.         $this->designation $designation;
  223.         return $this;
  224.     }
  225.     public function getDesignationCollectionFiltre(): ?string
  226.     {
  227.         return $this->designationCollectionFiltre;
  228.     }
  229.     public function setDesignationCollectionFiltre(string $designationCollectionFiltre): self
  230.     {
  231.         $this->designationCollectionFiltre $designationCollectionFiltre;
  232.         return $this;
  233.     }
  234.     public function getDesignationCollectionFiltreBis(): ?string
  235.     {
  236.         return $this->designationCollectionFiltreBis;
  237.     }
  238.     public function setDesignationCollectionFiltreBis(string $designationCollectionFiltreBis): self
  239.     {
  240.         $this->designationCollectionFiltreBis $designationCollectionFiltreBis;
  241.         return $this;
  242.     }
  243.     public function removeRelatedProduit(Produit $relatedProduit): self
  244.     {
  245.         if ($this->relatedProduits->removeElement($relatedProduit)) {
  246.             $relatedProduit->removeSubFamille($this);
  247.         }
  248.         return $this;
  249.     }
  250.     /**
  251.      * @return Collection|Produit[]
  252.      */
  253.     public function getProduits(): Collection
  254.     {
  255.         return $this->produits;
  256.     }
  257.     public function addProduit(Produit $produit): self
  258.     {
  259.         if (!$this->produits->contains($produit)) {
  260.             $this->produits[] = $produit;
  261.             $produit->addSubFamille($this);
  262.         }
  263.         return $this;
  264.     }
  265.     public function removeProduit(Produit $produit): self
  266.     {
  267.         if ($this->produits->removeElement($produit)) {
  268.             $produit->removeSubFamille($this);
  269.         }
  270.         return $this;
  271.     }
  272.     public function getFamilleProduit(): ?FamilleProduit
  273.     {
  274.         return $this->familleProduit;
  275.     }
  276.     public function setFamilleProduit(?FamilleProduit $familleProduit): self
  277.     {
  278.         $this->familleProduit $familleProduit;
  279.         return $this;
  280.     }
  281.     public function getSeoUrl(): ?string
  282.     {
  283.         return $this->seoUrl;
  284.     }
  285.     public function setSeoUrl(string $seoUrl): self
  286.     {
  287.         $this->seoUrl $seoUrl;
  288.         return $this;
  289.     }
  290.     
  291.     public function getNavbarText(): ?string
  292.     {
  293.         return $this->navbarText;
  294.     }
  295.     public function setNavbarText(string $navbarText): self
  296.     {
  297.         $this->navbarText $navbarText;
  298.         return $this;
  299.     }
  300.     public function getDescription(): ?string
  301.     {
  302.         return $this->description;
  303.     }
  304.     public function setDescription(?string $description): self
  305.     {
  306.         $this->description $description;
  307.         return $this;
  308.     }
  309.     public function getPlacement(): ?int
  310.     {
  311.         return $this->placement;
  312.     }
  313.     public function setPlacement(int $placement): self
  314.     {
  315.         $this->placement $placement;
  316.         return $this;
  317.     }
  318.     
  319.     public function getDescriptionFin(): ?string
  320.     {
  321.         return $this->descriptionFin;
  322.     }
  323.     public function setDescriptionFin(?string $descriptionFin): self
  324.     {
  325.         $this->descriptionFin $descriptionFin;
  326.         return $this;
  327.     }
  328.     public function getConfigurateur(): ?string
  329.     {
  330.         return $this->configurateur;
  331.     }
  332.     public function setConfigurateur(?string $configurateur): self
  333.     {
  334.         $this->configurateur $configurateur;
  335.         return $this;
  336.     }
  337.     /**
  338.      * @return Collection<int, SousFamilleType>
  339.      */
  340.     public function getSousFamilleTypes(): Collection
  341.     {
  342.         return $this->sousFamilleTypes;
  343.     }
  344.     public function addSousFamilleType(SousFamilleType $sousFamilleType): self
  345.     {
  346.         if (!$this->sousFamilleTypes->contains($sousFamilleType)) {
  347.             $this->sousFamilleTypes[] = $sousFamilleType;
  348.             $sousFamilleType->addSubFamille($this);
  349.         }
  350.         return $this;
  351.     }
  352.     public function removeSousFamilleType(SousFamilleType $sousFamilleType): self
  353.     {
  354.         if ($this->sousFamilleTypes->removeElement($sousFamilleType)) {
  355.             $sousFamilleType->removeSubFamille($this);
  356.         }
  357.         return $this;
  358.     }
  359. }