<?phpnamespace App\Entity;use App\Entity\Traits\EntityTrait;use App\Repository\FolderRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=FolderRepository::class) */class Folder{ use EntityTrait{ EntityTrait::__construct as private __entityConstruct; } /** * @ORM\Column(type="string", length=255) */ private $name; /** * @ORM\ManyToOne(targetEntity=Folder::class) */ private $folder_parent; /** * @ORM\OneToMany(targetEntity=Document::class, mappedBy="folder") */ private $documents; public function __construct() { $this->__entityConstruct(); $this->documents = new ArrayCollection(); } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getFolderParent(): ?self { return $this->folder_parent; } public function setFolderParent(?self $folder_parent): self { $this->folder_parent = $folder_parent; return $this; } /** * @return Collection|Document[] */ public function getDocuments(): Collection { return $this->documents; } public function addDocument(Document $document): self { if (!$this->documents->contains($document)) { $this->documents[] = $document; $document->setFolder($this); } return $this; } public function removeDocument(Document $document): self { if ($this->documents->removeElement($document)) { // set the owning side to null (unless already changed) if ($document->getFolder() === $this) { $document->setFolder(null); } } return $this; } public function __toString(){ $string = ''; if($this->getFolderParent() != null){ $string .= $this->getFolderParent()->__toString().' - '; } $string .= $this->name; return $string; }}