src/Entity/Formulaire.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FormulaireRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ORM\Entity(repositoryClass=FormulaireRepository::class)
  12.  */
  13. class Formulaire
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $nom;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $titre;
  29.     /**
  30.      * @ORM\Column(type="text", nullable=true)
  31.      */
  32.     private $descriptionDebut;
  33.     /**
  34.      * @ORM\Column(type="text", nullable=true)
  35.      */
  36.     private $descriptionFin;
  37.     /**
  38.      * @var \DateTime $dateCreation
  39.      *
  40.      * @Gedmo\Timestampable(on="create")
  41.      * @ORM\Column(type="datetime", nullable=true)
  42.      */
  43.     private $dateCreation;
  44.     /**
  45.      * @var \DateTime $dateModification
  46.      *
  47.      * @Gedmo\Timestampable(on="update")
  48.      * @ORM\Column(type="datetime", nullable=true)
  49.      */
  50.     private $dateModification;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=Projet::class, inversedBy="formulaires")
  53.      * @ORM\JoinColumn(nullable=false)
  54.      */
  55.     private $projet;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $idImport;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity=FormulaireEtape::class, mappedBy="formulaire", orphanRemoval=true)
  62.      * @ORM\OrderBy({"ordre" = "ASC"})
  63.      */
  64.     private $formulaireEtapes;
  65.     /**
  66.      * @ORM\OneToMany(targetEntity=Page::class, mappedBy="formulaire")
  67.      */
  68.     private $pages;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity=Article::class, mappedBy="formulaire")
  71.      */
  72.     private $articles;
  73.     public function __construct()
  74.     {
  75.         $this->formulaireEtapes = new ArrayCollection();
  76.         $this->pages = new ArrayCollection();
  77.         $this->articles = new ArrayCollection();
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getNom(): ?string
  84.     {
  85.         return $this->nom;
  86.     }
  87.     public function setNom(string $nom): self
  88.     {
  89.         $nom str_replace("|""-"$nom);
  90.         $nom str_replace(PHP_EOL''$nom);
  91.         $nom str_replace(array("\n""\r"), ''$nom);
  92.         $nom $this->slugify($nom);
  93.         $this->nom $nom;
  94.         return $this;
  95.     }
  96.     public function getTitre(): ?string
  97.     {
  98.         return $this->titre;
  99.     }
  100.     public function setTitre(string $titre): self
  101.     {
  102.         $titre str_replace("|""-"$titre);
  103.         $titre str_replace(PHP_EOL''$titre);
  104.         $titre str_replace(array("\n""\r"), ''$titre);
  105.         $this->titre $titre;
  106.         return $this;
  107.     }
  108.     public function getDescriptionDebut(): ?string
  109.     {
  110.         return $this->descriptionDebut;
  111.     }
  112.     public function setDescriptionDebut(?string $descriptionDebut): self
  113.     {
  114.         $descriptionDebut str_replace("|""-"$descriptionDebut);
  115.         $descriptionDebut str_replace(PHP_EOL''$descriptionDebut);
  116.         $descriptionDebut str_replace(array("\n""\r"), ''$descriptionDebut);
  117.         $this->descriptionDebut $descriptionDebut;
  118.         return $this;
  119.     }
  120.     public function getDescriptionFin(): ?string
  121.     {
  122.         return $this->descriptionFin;
  123.     }
  124.     public function setDescriptionFin(?string $descriptionFin): self
  125.     {
  126.         $descriptionFin str_replace("|""-"$descriptionFin);
  127.         $descriptionFin str_replace(PHP_EOL''$descriptionFin);
  128.         $descriptionFin str_replace(array("\n""\r"), ''$descriptionFin);
  129.         $this->descriptionFin $descriptionFin;
  130.         return $this;
  131.     }
  132.     public function getDateCreation(): ?\DateTimeInterface
  133.     {
  134.         return $this->dateCreation;
  135.     }
  136.     public function setDateCreation(?\DateTimeInterface $dateCreation): self
  137.     {
  138.         $this->dateCreation $dateCreation;
  139.         return $this;
  140.     }
  141.     public function getDateModification(): ?\DateTimeInterface
  142.     {
  143.         return $this->dateModification;
  144.     }
  145.     public function setDateModification(?\DateTimeInterface $dateModification): self
  146.     {
  147.         $this->dateModification $dateModification;
  148.         return $this;
  149.     }
  150.     public function getProjet(): ?Projet
  151.     {
  152.         return $this->projet;
  153.     }
  154.     public function setProjet(?Projet $projet): self
  155.     {
  156.         $this->projet $projet;
  157.         return $this;
  158.     }
  159.     public function getIdImport(): ?string
  160.     {
  161.         return $this->idImport;
  162.     }
  163.     public function setIdImport(?string $idImport): self
  164.     {
  165.         $this->idImport $idImport;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return Collection<int, FormulaireEtape>
  170.      */
  171.     public function getFormulaireEtapes(): Collection
  172.     {
  173.         return $this->formulaireEtapes;
  174.     }
  175.     public function addFormulaireEtape(FormulaireEtape $formulaireEtape): self
  176.     {
  177.         if (!$this->formulaireEtapes->contains($formulaireEtape)) {
  178.             $this->formulaireEtapes[] = $formulaireEtape;
  179.             $formulaireEtape->setFormulaire($this);
  180.         }
  181.         return $this;
  182.     }
  183.     public function removeFormulaireEtape(FormulaireEtape $formulaireEtape): self
  184.     {
  185.         if ($this->formulaireEtapes->removeElement($formulaireEtape)) {
  186.             // set the owning side to null (unless already changed)
  187.             if ($formulaireEtape->getFormulaire() === $this) {
  188.                 $formulaireEtape->setFormulaire(null);
  189.             }
  190.         }
  191.         return $this;
  192.     }
  193.     public function __toString(): string
  194.     {
  195.         return $this->getId() . " - " $this->getTitre();
  196.     }
  197.     public function getExportData()
  198.     {
  199.         $nom str_replace("|""-"$this->getNom());
  200.         $nom str_replace(PHP_EOL''$nom);
  201.         $nom str_replace(array("\n""\r"), ''$nom);
  202.         $titre str_replace("|""-"$this->getTitre());
  203.         $titre str_replace(PHP_EOL''$titre);
  204.         $titre str_replace(array("\n""\r"), ''$titre);
  205.         $descriptionDebut str_replace("|""-"$this->getDescriptionDebut());
  206.         $descriptionDebut str_replace(PHP_EOL''$descriptionDebut);
  207.         $descriptionDebut str_replace(array("\n""\r"), ''$descriptionDebut);
  208.         $descriptionFin str_replace("|""-"$this->getDescriptionFin());
  209.         $descriptionFin str_replace(PHP_EOL''$descriptionFin);
  210.         $descriptionFin str_replace(array("\n""\r"), ''$descriptionFin);
  211.         $data = [
  212.             'tb_form_id' => $this->getId(),
  213.             'tb_form_c_nom' => $nom,
  214.             'tb_form_c_nom_online' => $titre,
  215.             'tb_form_c_description_debut' => $descriptionDebut,
  216.             'tb_form_c_description_fin' => $descriptionFin,
  217.             'tb_form_id_import' => $this->getIdImport(),
  218.         ];
  219.         return $data;
  220.     }
  221.     /**
  222.      * @return Collection<int, Page>
  223.      */
  224.     public function getPages(): Collection
  225.     {
  226.         return $this->pages;
  227.     }
  228.     public function addPage(Page $page): self
  229.     {
  230.         if (!$this->pages->contains($page)) {
  231.             $this->pages[] = $page;
  232.             $page->setFormulaire($this);
  233.         }
  234.         return $this;
  235.     }
  236.     public function removePage(Page $page): self
  237.     {
  238.         if ($this->pages->removeElement($page)) {
  239.             // set the owning side to null (unless already changed)
  240.             if ($page->getFormulaire() === $this) {
  241.                 $page->setFormulaire(null);
  242.             }
  243.         }
  244.         return $this;
  245.     }
  246.     /**
  247.      * @return Collection<int, Article>
  248.      */
  249.     public function getArticles(): Collection
  250.     {
  251.         return $this->articles;
  252.     }
  253.     public function addArticle(Article $article): self
  254.     {
  255.         if (!$this->articles->contains($article)) {
  256.             $this->articles[] = $article;
  257.             $article->setFormulaire($this);
  258.         }
  259.         return $this;
  260.     }
  261.     public function removeArticle(Article $article): self
  262.     {
  263.         if ($this->articles->removeElement($article)) {
  264.             // set the owning side to null (unless already changed)
  265.             if ($article->getFormulaire() === $this) {
  266.                 $article->setFormulaire(null);
  267.             }
  268.         }
  269.         return $this;
  270.     }
  271.     
  272.     
  273.     public function slugify($string)
  274.     {
  275.         return strtolower(trim(preg_replace('~[^0-9a-z]+~i''-'html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i''$1'htmlentities($stringENT_QUOTES'UTF-8')), ENT_QUOTES'UTF-8')), '-'));
  276.     }
  277. }