<?php
namespace App\Entity;
use App\Entity\Traits\TimestampableTrait;
use App\Repository\SectionRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SectionRepository::class)]
class Section
{
use TimestampableTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'text')]
private $text;
#[ORM\ManyToOne(targetEntity: Workroom::class, inversedBy: 'sections')]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
private $workroom;
#[ORM\Column(type: 'string', length: 255, unique: true)]
private $uuid;
#[ORM\Column(type: 'integer', nullable: true)]
private $parentId;
#[ORM\Column(type: 'smallint')]
private $level;
#[ORM\Column(type: 'smallint')]
private $position;
#[ORM\Column(type: 'boolean', options: ['default' => 0])]
private $readonly;
#[ORM\Column(type: 'boolean', options: ['default' => 0])]
private $isTracking;
#[ORM\OneToMany(targetEntity: SectionRevision::class, mappedBy: 'section', cascade: ['persist'])]
private $sectionRevisions;
#[ORM\Column(type: 'integer', nullable: true)]
private $countWords;
#[ORM\Column(type: 'integer', nullable: true)]
private $countCharacters;
/** Chemin DOCX dans le storage Flysystem (Euro-Office) */
#[ORM\Column(type: 'string', length: 512, nullable: true)]
private ?string $docxPath = null;
/** Clé OnlyOffice — change à chaque save pour invalider le cache DocServer */
#[ORM\Column(type: 'string', length: 64, nullable: true)]
private ?string $docxKey = null;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $lastSavedAt = null;
public function getDocxPath(): ?string { return $this->docxPath; }
public function setDocxPath(?string $v): self { $this->docxPath = $v; return $this; }
public function getDocxKey(): ?string { return $this->docxKey; }
public function setDocxKey(?string $v): self { $this->docxKey = $v; return $this; }
public function regenerateDocxKey(): self { $this->docxKey = bin2hex(random_bytes(8)); return $this; }
public function getLastSavedAt(): ?\DateTimeImmutable { return $this->lastSavedAt; }
public function setLastSavedAt(?\DateTimeImmutable $v): self { $this->lastSavedAt = $v; return $this; }
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getText(): ?string
{
return $this->text;
}
/**
* @param string $text
* @return $this
*/
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
/**
* @return Workroom|null
*/
public function getWorkroom(): ?Workroom
{
return $this->workroom;
}
/**
* @param Workroom|null $workroom
* @return $this
*/
public function setWorkroom(?Workroom $workroom): self
{
$this->workroom = $workroom;
return $this;
}
/**
* @return int|null
*/
public function getParentId(): ?int
{
return $this->parentId;
}
/**
* @param int $parentId
* @return $this
*/
public function setParentId(?int $parentId): self
{
$this->parentId = $parentId;
return $this;
}
/**
* @return int|null
*/
public function getLevel(): ?int
{
return $this->level;
}
/**
* @param int $level
* @return $this
*/
public function setLevel(int $level): self
{
$this->level = $level;
return $this;
}
/**
* @return int|null
*/
public function getPosition(): ?int
{
return $this->position;
}
/**
* @param int $position
* @return $this
*/
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
/**
* @return string|null
*/
public function getUuid(): ?string
{
return $this->uuid;
}
/**
* @param string $uuid
* @return $this
*/
public function setUuid(string $uuid): self
{
$this->uuid = $uuid;
return $this;
}
/**
* @return int|null
*/
public function getReadonly(): ?int
{
return $this->readonly;
}
/**
* @param int $readonly
* @return $this
*/
public function setReadonly(int $readonly): self
{
$this->readonly = $readonly;
return $this;
}
/**
* @return bool|null
*/
public function getIsTracking(): ?bool
{
return $this->isTracking;
}
/**
* @param bool $isTracking
* @return $this
*/
public function setIsTracking(bool $isTracking): self
{
$this->isTracking = $isTracking;
return $this;
}
/**
* @return Collection|SectionRevision[]
*/
public function getSectionRevisions(): Collection
{
return $this->sectionRevisions;
}
/**
* @return $this
*/
public function addSectionRevision(SectionRevision $sectionRevision): self
{
if (!$this->sectionRevisions->contains($sectionRevision)) {
$this->sectionRevisions[] = $sectionRevision;
$sectionRevision->setSection($this);
}
return $this;
}
/**
* @return $this
*/
public function removeSectionRevision(SectionRevision $sectionRevision): self
{
if ($this->sectionRevisions->removeElement($sectionRevision)) {
// set the owning side to null (unless already changed)
if ($sectionRevision->getSection() === $this) {
$sectionRevision->setSection(null);
}
}
return $this;
}
public function getCountWords(): ?int
{
return $this->countWords;
}
public function setCountWords(?int $countWords): self
{
$this->countWords = $countWords;
return $this;
}
public function getCountCharacters(): ?int
{
return $this->countCharacters;
}
public function setCountCharacters(?int $countCharacters): self
{
$this->countCharacters = $countCharacters;
return $this;
}
}