src/Entity/Gestiform/Formations/Catalogue/Theme/Theme.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Catalogue\Theme;
  3. use App\Entity\AbstractEntity;
  4. use App\Entity\Common\Upload;
  5. use App\Entity\Gestiform\Admin\Tarifs\TarifVenteTheme;
  6. use App\Entity\Gestiform\Admin\Tarifs\TarifVenteThemeIntra;
  7. use App\Entity\Gestiform\Formations\Catalogue\Certification;
  8. use App\Entity\Gestiform\Formations\Catalogue\Parcours\Parcours;
  9. use App\Repository\Gestiform\Formations\Catalogue\Theme\ThemeRepository;
  10. use App\Trait\SortableEntity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. /**
  15.  * @ORM\Entity(repositoryClass=ThemeRepository::class)
  16.  */
  17. class Theme extends AbstractEntity
  18. {
  19.     use SortableEntity;
  20.     /**
  21.      * @ORM\Column(type="string", length=255, nullable=false)
  22.      */
  23.     private string $intitule;
  24.     /**
  25.      * @ORM\Column(type="string", length=255, nullable=true)
  26.      */
  27.      private ?string $code null;
  28.     /**
  29.      * @ORM\Column(type="string", length=255, nullable=true)
  30.      */
  31.     private ?string $altBanniere null;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private ?string $altVignette null;
  36.     /**
  37.      * @ORM\Column(type="string", length=255, nullable=true)
  38.      */
  39.     private ?string $couleur null;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, nullable=true)
  42.      */
  43.     private ?string $commentaire null;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private ?string $seotitre null;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private ?string $seodescription null;
  52.     /**
  53.      * @ORM\Column(type="string", length=255, nullable=true)
  54.      */
  55.     private ?string $path null;
  56.     /**
  57.      * @ORM\Column(type="boolean")
  58.      */
  59.     private ?bool $publication true;
  60.     /**
  61.      * @ORM\OneToOne(targetEntity=Upload::class, cascade={"persist", "remove"})
  62.      * @ORM\JoinColumn(nullable=true)
  63.      */
  64.     private ?Upload $vignette null;
  65.     /**
  66.      * @ORM\OneToOne(targetEntity=Upload::class, cascade={"persist", "remove"})
  67.      * @ORM\JoinColumn(nullable=true)
  68.      */
  69.     private ?Upload $banniere null;
  70.     /**
  71.      * @ORM\OneToMany(targetEntity=SousThemeTheme::class, mappedBy="theme")
  72.      */
  73.     private Collection $sousThemeThemes;
  74.     /**
  75.      * @ORM\OneToMany(targetEntity=Certification::class, mappedBy="theme")
  76.      */
  77.     private Collection $certifications;
  78.     /**
  79.      * @ORM\ManyToMany(targetEntity=Parcours::class, mappedBy="themes")
  80.      */
  81.     private Collection $parcours;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity=TarifVenteTheme::class, mappedBy="theme", cascade={"persist", "remove"})
  84.      */
  85.     private Collection $tarifsVentes;
  86.     /**
  87.      * @ORM\OneToMany(targetEntity=TarifVenteThemeIntra::class, mappedBy="theme", cascade={"persist", "remove"})
  88.      */
  89.     private Collection $tarifsVenteIntras;
  90.     /**
  91.      * @ORM\ManyToOne(targetEntity=TarifVenteTheme::class)
  92.      */
  93.     private ?TarifVenteTheme $tarifVenteDefaut null;
  94.     /**
  95.      * @ORM\ManyToOne(targetEntity=TarifVenteThemeIntra::class)
  96.      */
  97.     private ?TarifVenteThemeIntra $tarifventeintradefaut null;
  98.     /**
  99.      * @ORM\OneToMany(targetEntity=Parcours::class, mappedBy="theme")
  100.      */
  101.     private Collection $defaultParcours;
  102.     public function __construct()
  103.     {
  104.         $this->sousThemeThemes = new ArrayCollection();
  105.         $this->certifications = new ArrayCollection();
  106.         $this->parcours = new ArrayCollection();
  107.         $this->tarifsVentes = new ArrayCollection();
  108.         $this->tarifsVenteIntras = new ArrayCollection();
  109.         $this->defaultParcours = new ArrayCollection();
  110.     }
  111.     public function getIntitule(): ?string
  112.     {
  113.         return $this->intitule;
  114.     }
  115.     public function getTarifVenteActuel()
  116.     {
  117.         if (count($this->getTarifsVentes()) == 0) {
  118.             return $this->getTarifVenteDefaut();
  119.         }
  120.         $datedujour = new \DateTime();
  121.         $datedujour->setTime(00);
  122.         // retourne le tarif dans les dates actuelles
  123.         foreach ($this->getTarifsVentes() as $tarif) {
  124.             if ($tarif->getStart() <= $datedujour &&
  125.                 ($tarif->getEnd() >= $datedujour || is_null($tarif->getEnd()))) {
  126.                 return $tarif;
  127.             }
  128.         }
  129.         return $this->getTarifVenteDefaut();
  130.     }
  131.     public function getTarifVenteIntraActuel()
  132.     {
  133.         $datedujour = new \DateTime();
  134.         $datedujour->setTime(00);
  135.         // retourne le tarif dans les dates actuelles
  136.         foreach ($this->getTarifsVenteIntras() as $tarif) {
  137.             if ($tarif->getStart() <= $datedujour && ($tarif->getEnd() >= $datedujour || is_null($tarif->getEnd()))) {
  138.                 return $tarif;
  139.             }
  140.         }
  141.         return $this->getTarifVenteDefaut();
  142.     }
  143.     public function setIntitule(string $intitule): self
  144.     {
  145.         $this->intitule $intitule;
  146.         return $this;
  147.     }
  148.     public function getCode(): ?string
  149.     {
  150.         return $this->code;
  151.     }
  152.     public function setCode(?string $code): self
  153.     {
  154.         $this->code $code;
  155.         return $this;
  156.     }
  157.     public function getAltBanniere(): ?string
  158.     {
  159.         return $this->altBanniere;
  160.     }
  161.     public function setAltBanniere(?string $altBanniere): self
  162.     {
  163.         $this->altBanniere $altBanniere;
  164.         return $this;
  165.     }
  166.     public function getAltVignette(): ?string
  167.     {
  168.         return $this->altVignette;
  169.     }
  170.     public function setAltVignette(?string $altVignette): self
  171.     {
  172.         $this->altVignette $altVignette;
  173.         return $this;
  174.     }
  175.     public function getCouleur(): ?string
  176.     {
  177.         return $this->couleur;
  178.     }
  179.     public function setCouleur(?string $couleur): self
  180.     {
  181.         $this->couleur $couleur;
  182.         return $this;
  183.     }
  184.     public function getCommentaire(): ?string
  185.     {
  186.         return $this->commentaire;
  187.     }
  188.     public function setCommentaire(?string $commentaire): self
  189.     {
  190.         $this->commentaire $commentaire;
  191.         return $this;
  192.     }
  193.     public function getSeotitre(): ?string
  194.     {
  195.         return $this->seotitre;
  196.     }
  197.     public function setSeotitre(?string $seotitre): self
  198.     {
  199.         $this->seotitre $seotitre;
  200.         return $this;
  201.     }
  202.     public function getSeodescription(): ?string
  203.     {
  204.         return $this->seodescription;
  205.     }
  206.     public function setSeodescription(?string $seodescription): self
  207.     {
  208.         $this->seodescription $seodescription;
  209.         return $this;
  210.     }
  211.     public function getPublication(): ?bool
  212.     {
  213.         return $this->publication;
  214.     }
  215.     public function setPublication(?bool $publication): self
  216.     {
  217.         $this->publication $publication;
  218.         return $this;
  219.     }
  220.     public function getVignette(): ?Upload
  221.     {
  222.         return $this->vignette;
  223.     }
  224.     public function setVignette(?Upload $vignette): self
  225.     {
  226.         $this->vignette $vignette;
  227.         return $this;
  228.     }
  229.     public function getBanniere(): ?Upload
  230.     {
  231.         return $this->banniere;
  232.     }
  233.     public function setBanniere(?Upload $banniere): self
  234.     {
  235.         $this->banniere $banniere;
  236.         return $this;
  237.     }
  238.     public function getPath(): ?string
  239.     {
  240.         return $this->path;
  241.     }
  242.     public function setPath(?string $path): self
  243.     {
  244.         $this->path $path;
  245.         return $this;
  246.     }
  247.     /**
  248.      * @return Collection<int, SousThemeTheme>
  249.      */
  250.     public function getSousThemeThemes(): Collection
  251.     {
  252.         return $this->sousThemeThemes;
  253.     }
  254.     public function addSousThemeTheme(SousThemeTheme $sousThemeTheme): self
  255.     {
  256.         if (!$this->sousThemeThemes->contains($sousThemeTheme)) {
  257.             $this->sousThemeThemes->add($sousThemeTheme);
  258.             $sousThemeTheme->setTheme($this);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeSousThemeTheme(SousThemeTheme $sousThemeTheme): self
  263.     {
  264.         if ($this->sousThemeThemes->removeElement($sousThemeTheme)) {
  265.             // set the owning side to null (unless already changed)
  266.             if ($sousThemeTheme->getTheme() === $this) {
  267.                 $sousThemeTheme->setTheme(null);
  268.             }
  269.         }
  270.         return $this;
  271.     }
  272.     /**
  273.      * @return Collection<int, Parcours>
  274.      */
  275.     public function getParcours(): Collection
  276.     {
  277.         return $this->parcours;
  278.     }
  279.     public function addParcour(Parcours $parcours): self
  280.     {
  281.         if (!$this->parcours->contains($parcours)) {
  282.             $this->parcours->add($parcours);
  283.         }
  284.         return $this;
  285.     }
  286.     public function removeParcour(Parcours $parcours): self
  287.     {
  288.         $this->parcours->removeElement($parcours);
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection<int, Certification>
  293.      */
  294.     public function getCertifications(): Collection
  295.     {
  296.         return $this->certifications;
  297.     }
  298.     public function addCertification(Certification $certification): self
  299.     {
  300.         if (!$this->certifications->contains($certification)) {
  301.             $this->certifications->add($certification);
  302.             $certification->setTheme($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeCertification(Certification $certification): self
  307.     {
  308.         if ($this->certifications->removeElement($certification)) {
  309.             // set the owning side to null (unless already changed)
  310.             if ($certification->getTheme() === $this) {
  311.                 $certification->setTheme(null);
  312.             }
  313.         }
  314.         return $this;
  315.     }
  316.     public function isPublication(): ?bool
  317.     {
  318.         return $this->publication;
  319.     }
  320.     /**
  321.      * @return Collection<int, TarifVenteTheme>
  322.      */
  323.     public function getTarifsVentes(): Collection
  324.     {
  325.         return $this->tarifsVentes;
  326.     }
  327.     public function addTarifsVente(TarifVenteTheme $tarifsVente): self
  328.     {
  329.         if (!$this->tarifsVentes->contains($tarifsVente)) {
  330.             $this->tarifsVentes->add($tarifsVente);
  331.             $tarifsVente->setTheme($this);
  332.         }
  333.         return $this;
  334.     }
  335.     public function removeTarifsVente(TarifVenteTheme $tarifsVente): self
  336.     {
  337.         if ($this->tarifsVentes->removeElement($tarifsVente)) {
  338.             // set the owning side to null (unless already changed)
  339.             if ($tarifsVente->getTheme() === $this) {
  340.                 $tarifsVente->setTheme(null);
  341.             }
  342.         }
  343.         return $this;
  344.     }
  345.     /**
  346.      * @return Collection<int, TarifVenteThemeIntra>
  347.      */
  348.     public function getTarifsVenteIntras(): Collection
  349.     {
  350.         return $this->tarifsVenteIntras;
  351.     }
  352.     public function addTarifsVenteIntra(TarifVenteThemeIntra $tarifsVenteIntra): self
  353.     {
  354.         if (!$this->tarifsVenteIntras->contains($tarifsVenteIntra)) {
  355.             $this->tarifsVenteIntras->add($tarifsVenteIntra);
  356.             $tarifsVenteIntra->setTheme($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeTarifsVenteIntra(TarifVenteThemeIntra $tarifsVenteIntra): self
  361.     {
  362.         if ($this->tarifsVenteIntras->removeElement($tarifsVenteIntra)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($tarifsVenteIntra->getTheme() === $this) {
  365.                 $tarifsVenteIntra->setTheme(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370.     public function getTarifVenteDefaut(): ?TarifVenteTheme
  371.     {
  372.         return $this->tarifVenteDefaut;
  373.     }
  374.     public function setTarifVenteDefaut(?TarifVenteTheme $tarifVenteDefaut): self
  375.     {
  376.         $this->tarifVenteDefaut $tarifVenteDefaut;
  377.         return $this;
  378.     }
  379.     public function getTarifventeintradefaut(): ?TarifVenteThemeIntra
  380.     {
  381.         return $this->tarifventeintradefaut;
  382.     }
  383.     public function setTarifventeintradefaut(?TarifVenteThemeIntra $tarifventeintradefaut): self
  384.     {
  385.         $this->tarifventeintradefaut $tarifventeintradefaut;
  386.         return $this;
  387.     }
  388.     /**
  389.      * @return Collection<int, Parcours>
  390.      */
  391.     public function getDefaultParcours(): Collection
  392.     {
  393.         return $this->defaultParcours;
  394.     }
  395.     public function addDefaultParcour(Parcours $defaultParcour): self
  396.     {
  397.         if (!$this->defaultParcours->contains($defaultParcour)) {
  398.             $this->defaultParcours->add($defaultParcour);
  399.             $defaultParcour->setTheme($this);
  400.         }
  401.         return $this;
  402.     }
  403.     public function removeDefaultParcour(Parcours $defaultParcour): self
  404.     {
  405.         if ($this->defaultParcours->removeElement($defaultParcour)) {
  406.             // set the owning side to null (unless already changed)
  407.             if ($defaultParcour->getTheme() === $this) {
  408.                 $defaultParcour->setTheme(null);
  409.             }
  410.         }
  411.         return $this;
  412.     }
  413. }