src/Entity/Site/LocaleMere.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Site;
  3. use App\Repository\Site\LocaleMereRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Entity(repositoryClass=LocaleMereRepository::class)
  13.  * @UniqueEntity("seoUrl")
  14.  * @Vich\Uploadable
  15.  */
  16. class LocaleMere
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $titre;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $seoUrl;
  32.     //--------------------------------------------------------- 
  33.     //                  VICHUPLOADER propriété START
  34.     //--------------------------------------------------------- 
  35.     /**
  36.      * @ORM\Column(type="text", nullable=true)
  37.      */
  38.     private $imageEnTete;
  39.     /**
  40.      * @Vich\UploadableField(mapping="locale_mere", fileNameProperty="imageEnTete")
  41.      * @Assert\File(
  42.      *     maxSize = "2M",
  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"},
  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="date")
  52.      */
  53.     private $date;
  54.     //--------------------------------------------------------- 
  55.     //                  VICHUPLOADER propriété END
  56.     //--------------------------------------------------------- 
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private $metaTitle;
  61.     /**
  62.      * @ORM\Column(type="text", nullable=true)
  63.      */
  64.     private $metaDescription;
  65.     /**
  66.      * @ORM\Column(type="string", length=255, nullable=true)
  67.      */
  68.     private $imageAlt;
  69.     /**
  70.      * @ORM\Column(type="text")
  71.      */
  72.     private $contenu1;
  73.     /**
  74.      * @ORM\Column(type="text")
  75.      */
  76.     private $contenu2;
  77.     /**
  78.      * @ORM\Column(type="string", length=255)
  79.      */
  80.     private $latitude;
  81.     /**
  82.      * @ORM\Column(type="string", length=255)
  83.      */
  84.     private $longitude;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity=LocaleFille::class, mappedBy="localeMere", orphanRemoval=true, cascade={"all"})
  87.      */
  88.     private $localeFilles;
  89.     public function __construct()
  90.     {
  91.         $this->date = new \DateTime('now');
  92.         $this->localeFilles = new ArrayCollection();
  93.     }
  94.     public function __toString()
  95.     {
  96.         return $this->getTitre();
  97.     }
  98.     //--------------------------------------------------------- 
  99.     //                  VICHUPLOADER méthode START
  100.     //--------------------------------------------------------- 
  101.     public function setImageFile(File $url null)
  102.     {
  103.         $this->imageFile $url;
  104.         // VERY IMPORTANT:
  105.         // It is required that at least one field changes if you are using Doctrine,
  106.         // otherwise the event listeners won't be called and the file is lost
  107.         if ($url) {
  108.             // if 'updatedAt' is not defined in your entity, use another property
  109.             $this->date = new \DateTime('now');
  110.         }
  111.     }
  112.     public function getImageFile()
  113.     {
  114.         return $this->imageFile;
  115.     }
  116.     //--------------------------------------------------------- 
  117.     //                  VICHUPLOADER méthode END
  118.     //--------------------------------------------------------- 
  119.     public function getId(): ?int
  120.     {
  121.         return $this->id;
  122.     }
  123.     public function getTitre(): ?string
  124.     {
  125.         return $this->titre;
  126.     }
  127.     public function setTitre(string $titre): self
  128.     {
  129.         $this->titre $titre;
  130.         return $this;
  131.     }
  132.     public function getSeoUrl(): ?string
  133.     {
  134.         return $this->seoUrl;
  135.     }
  136.     public function setSeoUrl(string $seoUrl): self
  137.     {
  138.         $this->seoUrl $seoUrl;
  139.         return $this;
  140.     }
  141.     public function getImageEnTete(): ?string
  142.     {
  143.         return $this->imageEnTete;
  144.     }
  145.     public function setImageEnTete(?string $imageEnTete): self
  146.     {
  147.         $this->imageEnTete $imageEnTete;
  148.         return $this;
  149.     }
  150.     public function getMetaTitle(): ?string
  151.     {
  152.         return $this->metaTitle;
  153.     }
  154.     public function setMetaTitle(?string $metaTitle): self
  155.     {
  156.         $this->metaTitle $metaTitle;
  157.         return $this;
  158.     }
  159.     public function getMetaDescription(): ?string
  160.     {
  161.         return $this->metaDescription;
  162.     }
  163.     public function setMetaDescription(?string $metaDescription): self
  164.     {
  165.         $this->metaDescription $metaDescription;
  166.         return $this;
  167.     }
  168.     public function getImageAlt(): ?string
  169.     {
  170.         return $this->imageAlt;
  171.     }
  172.     public function setImageAlt(?string $imageAlt): self
  173.     {
  174.         $this->imageAlt $imageAlt;
  175.         return $this;
  176.     }
  177.     public function getContenu1(): ?string
  178.     {
  179.         return $this->contenu1;
  180.     }
  181.     public function setContenu1(string $contenu1): self
  182.     {
  183.         $this->contenu1 $contenu1;
  184.         return $this;
  185.     }
  186.     public function getContenu2(): ?string
  187.     {
  188.         return $this->contenu2;
  189.     }
  190.     public function setContenu2(string $contenu2): self
  191.     {
  192.         $this->contenu2 $contenu2;
  193.         return $this;
  194.     }
  195.     public function getLatitude(): ?string
  196.     {
  197.         return $this->latitude;
  198.     }
  199.     public function setLatitude(string $latitude): self
  200.     {
  201.         $this->latitude $latitude;
  202.         return $this;
  203.     }
  204.     public function getLongitude(): ?string
  205.     {
  206.         return $this->longitude;
  207.     }
  208.     public function setLongitude(string $longitude): self
  209.     {
  210.         $this->longitude $longitude;
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return Collection|LocaleFille[]
  215.      */
  216.     public function getLocaleFilles(): Collection
  217.     {
  218.         return $this->localeFilles;
  219.     }
  220.     public function addLocaleFille(LocaleFille $localeFille): self
  221.     {
  222.         if (!$this->localeFilles->contains($localeFille)) {
  223.             $this->localeFilles[] = $localeFille;
  224.             $localeFille->setLocaleMere($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeLocaleFille(LocaleFille $localeFille): self
  229.     {
  230.         if ($this->localeFilles->removeElement($localeFille)) {
  231.             // set the owning side to null (unless already changed)
  232.             if ($localeFille->getLocaleMere() === $this) {
  233.                 $localeFille->setLocaleMere(null);
  234.             }
  235.         }
  236.         return $this;
  237.     }
  238. }