src/Entity/Document/Document.php line 14

  1. <?php
  2. namespace App\Entity\Document;
  3. use App\Entity\User;
  4. use App\Repository\Document\DocumentRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassDocumentRepository::class)]
  10. #[ORM\Table(name'webdocument')]
  11. class Document
  12. {
  13.     public function className() {
  14.         return "Document";
  15.     }
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $title null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     private ?string $description null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?string $tags null;
  26.     #[ORM\OneToMany(mappedBy'document'targetEntityBlock::class)]
  27.     #[ORM\OrderBy(["blockorder" => "ASC"])]
  28.     private Collection $blocks;
  29.     #[ORM\ManyToOne(inversedBy'documents')]
  30.     private ?User $owner null;
  31.     #[ORM\Column(nullabletrue)]
  32.     private ?bool $isTemplate null;
  33.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  34.     private ?\DateTimeInterface $updateDate null;
  35.     public function __construct()
  36.     {
  37.         $this->blocks = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getTitle(): ?string
  44.     {
  45.         return $this->title;
  46.     }
  47.     public function setTitle(string $title): self
  48.     {
  49.         $this->title $title;
  50.         return $this;
  51.     }
  52.     public function getDescription(): ?string
  53.     {
  54.         return $this->description;
  55.     }
  56.     public function setDescription(?string $description): self
  57.     {
  58.         $this->description $description;
  59.         return $this;
  60.     }
  61.     public function getTags(): ?string
  62.     {
  63.         return $this->tags;
  64.     }
  65.     public function setTags(?string $tags): self
  66.     {
  67.         $this->tags $tags;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection<int, Block>
  72.      */
  73.     public function getBlocks(): Collection
  74.     {
  75.         return $this->blocks;
  76.     }
  77.     public function addBlock(Block $block): self
  78.     {
  79.         if (!$this->blocks->contains($block)) {
  80.             $this->blocks->add($block);
  81.             $block->setDocument($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeBlock(Block $block): self
  86.     {
  87.         if ($this->blocks->removeElement($block)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($block->getDocument() === $this) {
  90.                 $block->setDocument(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     public static function clone(Document $source)
  96.     {
  97.         $document = new Document();
  98.         $document->setTags($source->getTags());
  99.         $document->setDescription($source->getDescription());
  100.         $document->setTitle($source->getTitle());
  101.         $document->setOwner($source->getOwner());
  102.         foreach($source->getBlocks() as $block)
  103.             $document->addBlock(Block::clone($block));
  104.         return $document;
  105.     }
  106.     public function getOwner(): ?User
  107.     {
  108.         return $this->owner;
  109.     }
  110.     public function setOwner(?User $owner): self
  111.     {
  112.         $this->owner $owner;
  113.         return $this;
  114.     }
  115.     public function isIsTemplate(): ?bool
  116.     {
  117.         return $this->isTemplate;
  118.     }
  119.     public function setIsTemplate(?bool $isTemplate): self
  120.     {
  121.         $this->isTemplate $isTemplate;
  122.         return $this;
  123.     }
  124.     public function getUpdateDate(): ?\DateTimeInterface
  125.     {
  126.         return $this->updateDate;
  127.     }
  128.     public function setUpdateDate(?\DateTimeInterface $updateDate): self
  129.     {
  130.         $this->updateDate $updateDate;
  131.         return $this;
  132.     }
  133. }