src/Entity/Document.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DocumentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassDocumentRepository::class)]
  9. class Document
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $label null;
  17.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  18.     private ?\DateTimeInterface $date_creation null;
  19.     #[ORM\OneToMany(mappedBy'document'targetEntitySection::class, cascade: ['remove''persist'])]
  20.     private Collection $sections;
  21.     #[ORM\ManyToOne(inversedBy'documents')]
  22.     private ?Dossier $dossier null;
  23.     #[ORM\Column(options: ["default" => false])]
  24.     private ?bool $biblio null;
  25.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 1])]
  26.     private int $etat 1;
  27.     #[ORM\ManyToOne(inversedBy'documents')]
  28.     private ?Template $template null;
  29.     #[ORM\OneToMany(mappedBy'document'targetEntityVariablesGroup::class, cascade: ['remove''persist'])]
  30.     #[ORM\OrderBy(['ordre' => 'ASC'])]
  31.     private Collection $variablesGroups;
  32.     #[ORM\OneToMany(mappedBy'document'targetEntityFichier::class, cascade: ['remove''persist'])]
  33.     private Collection $fichiers;
  34.     #[ORM\OneToMany(mappedBy'document'targetEntityVariableValue::class, cascade: ['remove''persist'])]
  35.     private Collection $variableValues;
  36.     public function __construct()
  37.     {
  38.         $this->sections = new ArrayCollection();
  39.         $this->variablesGroups = new ArrayCollection();
  40.         $this->fichiers = new ArrayCollection();
  41.         $this->variableValues = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getLabel(): ?string
  48.     {
  49.         return $this->label;
  50.     }
  51.     public function setLabel(string $label): static
  52.     {
  53.         $this->label $label;
  54.         return $this;
  55.     }
  56.     public function getDateCreation(): ?\DateTimeInterface
  57.     {
  58.         return $this->date_creation;
  59.     }
  60.     public function setDateCreation(\DateTimeInterface $date_creation): static
  61.     {
  62.         $this->date_creation $date_creation;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, Section>
  67.      */
  68.     public function getSections(): Collection
  69.     {
  70.         return $this->sections;
  71.     }
  72.     public function addSection(Section $section): static
  73.     {
  74.         if (!$this->sections->contains($section)) {
  75.             $this->sections->add($section);
  76.             $section->setDocument($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeSection(Section $section): static
  81.     {
  82.         if ($this->sections->removeElement($section)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($section->getDocument() === $this) {
  85.                 $section->setDocument(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90.     public function getDossier(): ?Dossier
  91.     {
  92.         return $this->dossier;
  93.     }
  94.     public function setDossier(?Dossier $dossier): static
  95.     {
  96.         $this->dossier $dossier;
  97.         return $this;
  98.     }
  99.     public function isBiblio(): ?bool
  100.     {
  101.         return $this->biblio;
  102.     }
  103.     public function setBiblio(bool $biblio): static
  104.     {
  105.         $this->biblio $biblio;
  106.         return $this;
  107.     }
  108.     public function getTemplate(): ?Template
  109.     {
  110.         return $this->template;
  111.     }
  112.     public function setTemplate(?Template $template): static
  113.     {
  114.         $this->template $template;
  115.         return $this;
  116.     }
  117.     public function setVariablesGroups(Collection $variablesGroups): static
  118.     {
  119.         $this->variablesGroups $variablesGroups;
  120.         return $this;
  121.     }
  122.     /**
  123.      * @return Collection<int, VariablesGroup>
  124.      */
  125.     public function getVariablesGroups(): Collection
  126.     {
  127.         $iterator $this->variablesGroups->getIterator();
  128.         $iterator->uasort(fn($a$b) => $a->getOrdre() <=> $b->getOrdre());
  129.         return new ArrayCollection(iterator_to_array($iterator));
  130.     }
  131.     public function addVariablesGroup(VariablesGroup $variablesGroup): static
  132.     {
  133.         if (!$this->variablesGroups->contains($variablesGroup)) {
  134.             $this->variablesGroups->add($variablesGroup);
  135.             $variablesGroup->setDocument($this);
  136.         }
  137.         return $this;
  138.     }
  139.     public function removeVariablesGroup(VariablesGroup $variablesGroup): static
  140.     {
  141.         if ($this->variablesGroups->removeElement($variablesGroup)) {
  142.             // set the owning side to null (unless already changed)
  143.             if ($variablesGroup->getDocument() === $this) {
  144.                 $variablesGroup->setDocument(null);
  145.             }
  146.         }
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection<int, Fichier>
  151.      */
  152.     public function getFichiers(): Collection
  153.     {
  154.         return $this->fichiers;
  155.     }
  156.     public function addFichier(Fichier $fichier): static
  157.     {
  158.         if (!$this->fichiers->contains($fichier)) {
  159.             $this->fichiers->add($fichier);
  160.             $fichier->setDocument($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeFichier(Fichier $fichier): static
  165.     {
  166.         if ($this->fichiers->removeElement($fichier)) {
  167.             // set the owning side to null (unless already changed)
  168.             if ($fichier->getDocument() === $this) {
  169.                 $fichier->setDocument(null);
  170.             }
  171.         }
  172.         return $this;
  173.     }
  174.     public function getBlocs(): array
  175.     {
  176.         $blocs = [];
  177.         foreach ($this->sections as $section) {
  178.             foreach ($section->getBlocs() as $bloc) {
  179.                 $blocs[] = $bloc;
  180.             }
  181.         }
  182.         return $blocs;
  183.     }
  184.     /**
  185.      * @return Collection<int, VariableValue>
  186.      */
  187.     public function getVariableValues(): Collection
  188.     {
  189.         return $this->variableValues;
  190.     }
  191.     public function addVariableValue(VariableValue $variableValue): static
  192.     {
  193.         if (!$this->variableValues->contains($variableValue)) {
  194.             $this->variableValues->add($variableValue);
  195.             $variableValue->setDocument($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeVariableValue(VariableValue $variableValue): static
  200.     {
  201.         if ($this->variableValues->removeElement($variableValue)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($variableValue->getDocument() === $this) {
  204.                 $variableValue->setDocument(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     public function getEtat(): int
  210.     {
  211.         return $this->etat;
  212.     }
  213.     public function setEtat(int $etat): static
  214.     {
  215.         $this->etat $etat;
  216.         return $this;
  217.     }
  218. }