<?php
namespace App\Entity;
use App\Repository\DocumentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: DocumentRepository::class)]
class Document
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'documents')]
private ?Project $projet = null;
#[ORM\Column(length: 255)]
private ?string $label = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $date_creation = null;
#[ORM\OneToMany(mappedBy: 'document', targetEntity: Section::class, cascade: ['remove', 'persist'])]
private Collection $sections;
#[ORM\ManyToOne(inversedBy: 'documents')]
private ?Dossier $dossier = null;
#[ORM\ManyToOne(inversedBy: 'documents')]
private ?DossierDocType $doc_type = null;
#[ORM\Column(options: ["default" => false])]
private ?bool $biblio = null;
#[ORM\ManyToOne(inversedBy: 'documents')]
private ?Template $template = null;
// Add cascade={"persist"} for VariablesGroup relationship
#[ORM\OneToMany(mappedBy: 'document', targetEntity: VariablesGroup::class, cascade: ['remove', 'persist'])]
private Collection $variablesGroups;
// Add cascade={"persist"} for Fichier relationship
#[ORM\OneToMany(mappedBy: 'document', targetEntity: Fichier::class, cascade: ['remove', 'persist'])]
private Collection $fichiers;
// Add cascade={"persist"} for Bloc relationship
#[ORM\OneToMany(mappedBy: 'document', targetEntity: Bloc::class, cascade: ['remove', 'persist'])]
private Collection $blocs;
// Add cascade={"persist"} for VariableValue relationship
#[ORM\OneToMany(mappedBy: 'document', targetEntity: VariableValue::class, cascade: ['remove', 'persist'])]
private Collection $variableValues;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'parent')]
private ?self $document = null;
#[ORM\OneToMany(mappedBy: 'document', targetEntity: self::class)]
private Collection $parent;
public function __construct()
{
$this->sections = new ArrayCollection();
$this->variablesGroups = new ArrayCollection();
$this->fichiers = new ArrayCollection();
$this->blocs = new ArrayCollection();
$this->variableValues = new ArrayCollection();
$this->parent = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getProjet(): ?Project
{
return $this->projet;
}
public function setProjet(?Project $projet): static
{
$this->projet = $projet;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
public function getDateCreation(): ?\DateTimeInterface
{
return $this->date_creation;
}
public function setDateCreation(\DateTimeInterface $date_creation): static
{
$this->date_creation = $date_creation;
return $this;
}
// Add this method to get the associated Project
public function getProject(): ?Project
{
return $this->getProjet();
}
/**
* @return Collection<int, Section>
*/
public function getSections(): Collection
{
return $this->sections;
}
public function addSection(Section $section): static
{
if (!$this->sections->contains($section)) {
$this->sections->add($section);
$section->setDocument($this);
}
return $this;
}
public function removeSection(Section $section): static
{
if ($this->sections->removeElement($section)) {
// set the owning side to null (unless already changed)
if ($section->getDocument() === $this) {
$section->setDocument(null);
}
}
return $this;
}
public function getDossier(): ?Dossier
{
return $this->dossier;
}
public function setDossier(?Dossier $dossier): static
{
$this->dossier = $dossier;
return $this;
}
public function getDocType(): ?DossierDocType
{
return $this->doc_type;
}
public function setDocType(?DossierDocType $doc_type): static
{
$this->doc_type = $doc_type;
return $this;
}
public function isBiblio(): ?bool
{
return $this->biblio;
}
public function setBiblio(bool $biblio): static
{
$this->biblio = $biblio;
return $this;
}
public function getTemplate(): ?Template
{
return $this->template;
}
public function setTemplate(?Template $template): static
{
$this->template = $template;
return $this;
}
/**
* @return Collection<int, VariablesGroup>
*/
public function getVariablesGroups(): Collection
{
return $this->variablesGroups;
}
public function addVariablesGroup(VariablesGroup $variablesGroup): static
{
if (!$this->variablesGroups->contains($variablesGroup)) {
$this->variablesGroups->add($variablesGroup);
$variablesGroup->setDocument($this);
}
return $this;
}
public function removeVariablesGroup(VariablesGroup $variablesGroup): static
{
if ($this->variablesGroups->removeElement($variablesGroup)) {
// set the owning side to null (unless already changed)
if ($variablesGroup->getDocument() === $this) {
$variablesGroup->setDocument(null);
}
}
return $this;
}
/**
* @return Collection<int, Fichier>
*/
public function getFichiers(): Collection
{
return $this->fichiers;
}
public function addFichier(Fichier $fichier): static
{
if (!$this->fichiers->contains($fichier)) {
$this->fichiers->add($fichier);
$fichier->setDocument($this);
}
return $this;
}
public function removeFichier(Fichier $fichier): static
{
if ($this->fichiers->removeElement($fichier)) {
// set the owning side to null (unless already changed)
if ($fichier->getDocument() === $this) {
$fichier->setDocument(null);
}
}
return $this;
}
/**
* @return Collection<int, Bloc>
*/
public function getBlocs(): Collection
{
return $this->blocs;
}
public function addBloc(Bloc $bloc): static
{
if (!$this->blocs->contains($bloc)) {
$this->blocs->add($bloc);
$bloc->setDocument($this);
}
return $this;
}
public function removeBloc(Bloc $bloc): static
{
if ($this->blocs->removeElement($bloc)) {
// set the owning side to null (unless already changed)
if ($bloc->getDocument() === $this) {
$bloc->setDocument(null);
}
}
return $this;
}
/**
* @return Collection<int, VariableValue>
*/
public function getVariableValues(): Collection
{
return $this->variableValues;
}
public function addVariableValue(VariableValue $variableValue): static
{
if (!$this->variableValues->contains($variableValue)) {
$this->variableValues->add($variableValue);
$variableValue->setDocument($this);
}
return $this;
}
public function removeVariableValue(VariableValue $variableValue): static
{
if ($this->variableValues->removeElement($variableValue)) {
// set the owning side to null (unless already changed)
if ($variableValue->getDocument() === $this) {
$variableValue->setDocument(null);
}
}
return $this;
}
public function getDocument(): ?self
{
return $this->document;
}
public function setDocument(?self $document): static
{
$this->document = $document;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getParent(): Collection
{
return $this->parent;
}
public function addParent(self $parent): static
{
if (!$this->parent->contains($parent)) {
$this->parent->add($parent);
$parent->setDocument($this);
}
return $this;
}
public function removeParent(self $parent): static
{
if ($this->parent->removeElement($parent)) {
// set the owning side to null (unless already changed)
if ($parent->getDocument() === $this) {
$parent->setDocument(null);
}
}
return $this;
}
}