<?php
namespace App\Entity;
use App\Repository\SectionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SectionRepository::class)]
class Section
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $titre = null;
#[ORM\Column]
private ?int $ordre = null;
#[ORM\Column]
private ?bool $actif = true;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: Rubrique::class, cascade: ['remove', 'persist'])]
private Collection $rubriques;
#[ORM\ManyToOne(inversedBy: 'sections')]
private ?Document $document = null;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'subSections')]
private ?self $parentSection = null;
#[ORM\OneToMany(mappedBy: 'parentSection', targetEntity: self::class, cascade: ['remove', 'persist'])]
private Collection $subSections;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: Element::class)]
private Collection $elements;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: Bloc::class, cascade: ['remove', 'persist'] )]
private Collection $bloc;
public function __construct()
{
$this->rubriques = new ArrayCollection();
$this->subSections = new ArrayCollection();
$this->elements = new ArrayCollection();
$this->bloc = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): static
{
$this->titre = $titre;
return $this;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setOrdre(int $ordre): static
{
$this->ordre = $ordre;
return $this;
}
public function isActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): static
{
$this->actif = $actif;
return $this;
}
/**
* @return Collection<int, Rubrique>
*/
public function getRubriques(): Collection
{
return $this->rubriques;
}
public function addRubrique(Rubrique $rubrique): static
{
if (!$this->rubriques->contains($rubrique)) {
$this->rubriques->add($rubrique);
$rubrique->setSection($this);
}
return $this;
}
public function removeRubrique(Rubrique $rubrique): static
{
if ($this->rubriques->removeElement($rubrique)) {
// set the owning side to null (unless already changed)
if ($rubrique->getSection() === $this) {
$rubrique->setSection(null);
}
}
return $this;
}
public function getDocument(): ?Document
{
return $this->document;
}
public function setDocument(?Document $document): static
{
$this->document = $document;
return $this;
}
public function getParentSection(): ?self
{
return $this->parentSection;
}
public function setParentSection(?self $parentSection): static
{
$this->parentSection = $parentSection;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getSubSections(): Collection
{
return $this->subSections;
}
public function addSubSection(self $subSection): static
{
if (!$this->subSections->contains($subSection)) {
$this->subSections->add($subSection);
$subSection->setParentSection($this);
}
return $this;
}
public function removeSubSection(self $subSection): static
{
if ($this->subSections->removeElement($subSection)) {
// set the owning side to null (unless already changed)
if ($subSection->getParentSection() === $this) {
$subSection->setParentSection(null);
}
}
return $this;
}
/**
* @return Collection<int, Element>
*/
public function getElements(): Collection
{
return $this->elements;
}
public function addElement(Element $element): static
{
if (!$this->elements->contains($element)) {
$this->elements->add($element);
$element->setSection($this);
}
return $this;
}
public function removeElement(Element $element): static
{
if ($this->elements->removeElement($element)) {
// set the owning side to null (unless already changed)
if ($element->getSection() === $this) {
$element->setSection(null);
}
}
return $this;
}
/**
* @return Collection<int, Bloc>
*/
public function getBloc(): Collection
{
return $this->bloc;
}
public function addBloc(Bloc $bloc): static
{
if (!$this->bloc->contains($bloc)) {
$this->bloc->add($bloc);
$bloc->setSection($this);
}
return $this;
}
public function removeBloc(Bloc $bloc): static
{
if ($this->bloc->removeElement($bloc)) {
// set the owning side to null (unless already changed)
if ($bloc->getSection() === $this) {
$bloc->setSection(null);
}
}
return $this;
}
}