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