src/Entity/Document/Block.php line 12
<?phpnamespace App\Entity\Document;use App\Entity\User;use App\Repository\Document\BlockRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use App\Entity\Document as Document;#[ORM\Entity(repositoryClass: BlockRepository::class)]class Block{const TYPE_TEXT = 0;const TYPE_PAGEBREAK = 1;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(type: Types::TEXT)]private ?string $content = null;#[ORM\Column(length: 255, nullable: true)]private ?string $title = null;#[ORM\Column(length: 255, nullable: true)]private ?string $description = null;#[ORM\Column(length: 255, nullable: true)]private ?string $tags = null;#[ORM\ManyToOne(inversedBy: 'blocks')]#[ORM\JoinColumn(nullable: true)]private ?Document $document = null;#[ORM\Column(nullable: true)]private ?int $blockorder = null;#[ORM\ManyToOne]private ?User $owner = null;#[ORM\Column(nullable: true)]private ?int $idInDoc = null; // identifies current block within the document#[ORM\ManyToOne(inversedBy: 'blocks')]private ?BlockCategory $category = null;#[ORM\Column(options: ["default" => 0])]private ?int $type = self::TYPE_TEXT;public function getId(): ?int{return $this->id;}public function getContent(): ?string{return $this->content;}/* works the same as getContent but replaces [variables] with associated values* $data is an associative array ["variable" => "value", "variable2" => "value2" ...]*/public function getHydratedContent($data): ?string{$search = [];$replace = [];foreach($data as $key => $value) {$search[] = "[".$key."]";$replace[] = $value;}$hydrated = str_replace($search, $replace, $this->getContent());return $hydrated;}public function setContent(string $content): self{$this->content = $content;return $this;}public function getTitle(): ?string{return $this->title;}public function setTitle(?string $title): self{$this->title = $title;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getTags(): ?string{return $this->tags;}public function setTags(?string $tags): self{$this->tags = $tags;return $this;}public function getDocument(): ?Document{return $this->document;}public function setDocument(?Document $document): self{$this->document = $document;return $this;}public function getBlockorder(): ?int{return $this->blockorder;}public function setBlockorder(int $blockorder): self{$this->blockorder = $blockorder;return $this;}public static function clone(Block $source){$block = new Block();$block->setTags($source->getTags());$block->setDescription($source->getDescription());$block->setTitle($source->getTitle());$block->setContent($source->getContent());$block->setBlockorder($source->getBlockorder());$block->setOwner($source->getOwner());$block->setIdInDoc($source->getIdInDoc());return $block;}public function getOwner(): ?User{return $this->owner;}public function setOwner(?User $owner): self{$this->owner = $owner;return $this;}/*** @return int|null* documentId is a way to identify a block within a document, for comparison purposes between different versions.*/public function getIdInDoc(): ?int{return $this->idInDoc;}public function setIdInDoc(?int $idInDoc): self{$this->idInDoc = $idInDoc;return $this;}public function toArray(){return ["id" => $this->getId(),"tags" => $this->getTags(),"description" => $this->getDescription(),"title" => $this->getTitle(),"content" => $this->getContent(),"categoryTitle" => $this->getCategory() ? $this->getCategory()->getTitle() : "","categoryId" => $this->getCategory() ? $this->getCategory()->getId() : "0"];}public function getCategory(): ?BlockCategory{return $this->category;}public function setCategory(?BlockCategory $category): self{$this->category = $category;return $this;}public function getType(): ?int{return $this->type;}public function setType(int $type): static{$this->type = $type;return $this;}}