src/Entity/Document.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DocumentRepository;
  4. use App\Entity\Bloc;
  5. use App\Entity\DocumentStructure;
  6. use App\Entity\DocumentStyle;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. #[ORM\Entity(repositoryClassDocumentRepository::class)]
  12. class Document
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $label null;
  20.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  21.     private ?\DateTimeInterface $date_creation null;
  22.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  23.     private ?\DateTimeInterface $date_modification null;
  24.     #[ORM\OneToMany(mappedBy'document'targetEntitySection::class, cascade: ['remove''persist'])]
  25.     private Collection $sections;
  26.     #[ORM\OneToMany(mappedBy'document'targetEntityBloc::class, cascade: ['remove''persist'])]
  27.     #[ORM\OrderBy(['ordre' => 'ASC'])]
  28.     private Collection $directBlocs;
  29.     #[ORM\ManyToOne(inversedBy'documents')]
  30.     private ?Dossier $dossier null;
  31.     #[ORM\Column(options: ["default" => false])]
  32.     private ?bool $biblio null;
  33.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 1])]
  34.     private int $etat 1;
  35.     #[ORM\ManyToOne(inversedBy'documents')]
  36.     private ?Template $template null;
  37.     #[ORM\ManyToOne(targetEntityDocumentStructure::class)]
  38.     #[ORM\JoinColumn(name'mise_en_page_id'nullabletrue)]
  39.     private ?DocumentStructure $structure null;
  40.     #[ORM\ManyToOne(targetEntityDocumentStyle::class)]
  41.     #[ORM\JoinColumn(name'theme_id'nullabletrue)]
  42.     private ?DocumentStyle $style null;
  43.     #[ORM\OneToMany(mappedBy'document'targetEntityVariablesGroup::class, cascade: ['remove''persist'])]
  44.     private Collection $variablesGroups;
  45.     #[ORM\OneToMany(mappedBy'document'targetEntityFichier::class, cascade: ['remove''persist'])]
  46.     private Collection $fichiers;
  47.     #[ORM\OneToMany(mappedBy'document'targetEntityTemplateDocument::class, cascade: ['remove''persist'])]
  48.     private Collection $templateDocuments;
  49.     #[ORM\OneToMany(mappedBy'document'targetEntityVariableValue::class, cascade: ['remove''persist'])]
  50.     private Collection $variableValues;
  51.     public function __construct()
  52.     {
  53.         $this->sections      = new ArrayCollection();
  54.         $this->directBlocs   = new ArrayCollection();
  55.         $this->variablesGroups = new ArrayCollection();
  56.         $this->fichiers      = new ArrayCollection();
  57.         $this->variableValues    = new ArrayCollection();
  58.         $this->templateDocuments = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getLabel(): ?string
  65.     {
  66.         return $this->label;
  67.     }
  68.     public function setLabel(string $label): static
  69.     {
  70.         $this->label $label;
  71.         return $this;
  72.     }
  73.     public function getDateCreation(): ?\DateTimeInterface
  74.     {
  75.         return $this->date_creation;
  76.     }
  77.     public function setDateCreation(\DateTimeInterface $date_creation): static
  78.     {
  79.         $this->date_creation $date_creation;
  80.         return $this;
  81.     }
  82.     public function getDateModification(): ?\DateTimeInterface
  83.     {
  84.         return $this->date_modification;
  85.     }
  86.     public function touchDateModification(): static
  87.     {
  88.         $this->date_modification = new \DateTime();
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, Section>
  93.      */
  94.     public function getSections(): Collection
  95.     {
  96.         return $this->sections;
  97.     }
  98.     public function addSection(Section $section): static
  99.     {
  100.         if (!$this->sections->contains($section)) {
  101.             $this->sections->add($section);
  102.             $section->setDocument($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeSection(Section $section): static
  107.     {
  108.         if ($this->sections->removeElement($section)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($section->getDocument() === $this) {
  111.                 $section->setDocument(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116.     public function getDirectBlocs(): Collection
  117.     {
  118.         return $this->directBlocs;
  119.     }
  120.     public function addDirectBloc(Bloc $bloc): static
  121.     {
  122.         if (!$this->directBlocs->contains($bloc)) {
  123.             $this->directBlocs->add($bloc);
  124.             $bloc->setDocument($this);
  125.         }
  126.         return $this;
  127.     }
  128.     public function removeDirectBloc(Bloc $bloc): static
  129.     {
  130.         if ($this->directBlocs->removeElement($bloc)) {
  131.             if ($bloc->getDocument() === $this) {
  132.                 $bloc->setDocument(null);
  133.             }
  134.         }
  135.         return $this;
  136.     }
  137.     public function getDossier(): ?Dossier
  138.     {
  139.         return $this->dossier;
  140.     }
  141.     public function setDossier(?Dossier $dossier): static
  142.     {
  143.         $this->dossier $dossier;
  144.         return $this;
  145.     }
  146.     public function isBiblio(): ?bool
  147.     {
  148.         return $this->biblio;
  149.     }
  150.     public function setBiblio(bool $biblio): static
  151.     {
  152.         $this->biblio $biblio;
  153.         return $this;
  154.     }
  155.     public function getTemplate(): ?Template
  156.     {
  157.         return $this->template;
  158.     }
  159.     public function setTemplate(?Template $template): static
  160.     {
  161.         $this->template $template;
  162.         return $this;
  163.     }
  164.     public function getStructure(): ?DocumentStructure
  165.     {
  166.         return $this->structure;
  167.     }
  168.     public function setStructure(?DocumentStructure $structure): static
  169.     {
  170.         $this->structure $structure;
  171.         return $this;
  172.     }
  173.     public function getStyle(): ?DocumentStyle
  174.     {
  175.         return $this->style;
  176.     }
  177.     public function setStyle(?DocumentStyle $style): static
  178.     {
  179.         $this->style $style;
  180.         return $this;
  181.     }
  182.     public function setVariablesGroups(Collection $variablesGroups): static
  183.     {
  184.         $this->variablesGroups $variablesGroups;
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, VariablesGroup>
  189.      */
  190.     public function getVariablesGroups(): Collection
  191.     {
  192.         // Document variables don't need sorting - they're managed directly
  193.         return $this->variablesGroups;
  194.     }
  195.     public function addVariablesGroup(VariablesGroup $variablesGroup): static
  196.     {
  197.         if (!$this->variablesGroups->contains($variablesGroup)) {
  198.             $this->variablesGroups->add($variablesGroup);
  199.             $variablesGroup->setDocument($this);
  200.         }
  201.         return $this;
  202.     }
  203.     public function removeVariablesGroup(VariablesGroup $variablesGroup): static
  204.     {
  205.         if ($this->variablesGroups->removeElement($variablesGroup)) {
  206.             // set the owning side to null (unless already changed)
  207.             if ($variablesGroup->getDocument() === $this) {
  208.                 $variablesGroup->setDocument(null);
  209.             }
  210.         }
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return Collection<int, Fichier>
  215.      */
  216.     public function getFichiers(): Collection
  217.     {
  218.         return $this->fichiers;
  219.     }
  220.     public function addFichier(Fichier $fichier): static
  221.     {
  222.         if (!$this->fichiers->contains($fichier)) {
  223.             $this->fichiers->add($fichier);
  224.             $fichier->setDocument($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeFichier(Fichier $fichier): static
  229.     {
  230.         if ($this->fichiers->removeElement($fichier)) {
  231.             // set the owning side to null (unless already changed)
  232.             if ($fichier->getDocument() === $this) {
  233.                 $fichier->setDocument(null);
  234.             }
  235.         }
  236.         return $this;
  237.     }
  238.     public function getBlocs(): array
  239.     {
  240.         $blocs = [];
  241.         foreach ($this->sections as $section) {
  242.             foreach ($section->getBlocs() as $bloc) {
  243.                 $blocs[] = $bloc;
  244.             }
  245.         }
  246.         return $blocs;
  247.     }
  248.     /**
  249.      * @return Collection<int, VariableValue>
  250.      */
  251.     public function getVariableValues(): Collection
  252.     {
  253.         return $this->variableValues;
  254.     }
  255.     public function addVariableValue(VariableValue $variableValue): static
  256.     {
  257.         if (!$this->variableValues->contains($variableValue)) {
  258.             $this->variableValues->add($variableValue);
  259.             $variableValue->setDocument($this);
  260.         }
  261.         return $this;
  262.     }
  263.     public function removeVariableValue(VariableValue $variableValue): static
  264.     {
  265.         if ($this->variableValues->removeElement($variableValue)) {
  266.             // set the owning side to null (unless already changed)
  267.             if ($variableValue->getDocument() === $this) {
  268.                 $variableValue->setDocument(null);
  269.             }
  270.         }
  271.         return $this;
  272.     }
  273.     public function getEtat(): int
  274.     {
  275.         return $this->etat;
  276.     }
  277.     public function setEtat(int $etat): static
  278.     {
  279.         $this->etat $etat;
  280.         return $this;
  281.     }
  282.     /**
  283.      * @return Collection<int, TemplateDocument>
  284.      */
  285.     public function getTemplateDocuments(): Collection
  286.     {
  287.         return $this->templateDocuments;
  288.     }
  289.     public function addTemplateDocument(TemplateDocument $td): static
  290.     {
  291.         if (!$this->templateDocuments->contains($td)) {
  292.             $this->templateDocuments->add($td);
  293.             $td->setDocument($this);
  294.         }
  295.         return $this;
  296.     }
  297.     public function removeTemplateDocument(TemplateDocument $td): static
  298.     {
  299.         if ($this->templateDocuments->removeElement($td)) {
  300.             if ($td->getDocument() === $this) {
  301.                 $td->setDocument(null);
  302.             }
  303.         }
  304.         return $this;
  305.     }
  306. }