- Basic HTML templates
- Created entities & new migration - Added packages symfony/stimulus-bundle & symfony/webpack-encore-bundle
This commit is contained in:
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\CommentRepository;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: CommentRepository::class)]
|
||||
class Comment
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'comments')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?DomainPage $page = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'comments')]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
private ?string $markdown = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
private ?string $html = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'childComments')]
|
||||
private ?self $parentComment = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'parentComment', targetEntity: self::class)]
|
||||
private Collection $childComments;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $score = null;
|
||||
|
||||
#[ORM\Column(length: 32)]
|
||||
private ?string $state = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?DateTimeInterface $updatedAt = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?DateTimeInterface $deletedAt = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?User $deletedByUser = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->childComments = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMarkdown(): ?string
|
||||
{
|
||||
return $this->markdown;
|
||||
}
|
||||
|
||||
public function setMarkdown(string $markdown): static
|
||||
{
|
||||
$this->markdown = $markdown;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHtml(): ?string
|
||||
{
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
public function setHtml(string $html): static
|
||||
{
|
||||
$this->html = $html;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParentComment(): ?self
|
||||
{
|
||||
return $this->parentComment;
|
||||
}
|
||||
|
||||
public function setParentComment(?self $parentComment): static
|
||||
{
|
||||
$this->parentComment = $parentComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public function getChildComments(): Collection
|
||||
{
|
||||
return $this->childComments;
|
||||
}
|
||||
|
||||
public function addChildComment(self $childComment): static
|
||||
{
|
||||
if (!$this->childComments->contains($childComment)) {
|
||||
$this->childComments->add($childComment);
|
||||
$childComment->setParentComment($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeChildComment(self $childComment): static
|
||||
{
|
||||
if ($this->childComments->removeElement($childComment)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($childComment->getParentComment() === $this) {
|
||||
$childComment->setParentComment(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getScore(): ?int
|
||||
{
|
||||
return $this->score;
|
||||
}
|
||||
|
||||
public function setScore(int $score): static
|
||||
{
|
||||
$this->score = $score;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getState(): ?string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function setState(string $state): static
|
||||
{
|
||||
$this->state = $state;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(DateTimeImmutable $createdAt): static
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?DateTimeInterface $updatedAt): static
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDeletedAt(): ?DateTimeInterface
|
||||
{
|
||||
return $this->deletedAt;
|
||||
}
|
||||
|
||||
public function setDeletedAt(?DateTimeInterface $deletedAt): static
|
||||
{
|
||||
$this->deletedAt = $deletedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDeletedByUser(): ?User
|
||||
{
|
||||
return $this->deletedByUser;
|
||||
}
|
||||
|
||||
public function setDeletedByUser(?User $deletedByUser): static
|
||||
{
|
||||
$this->deletedByUser = $deletedByUser;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPage(): ?DomainPage
|
||||
{
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
public function setPage(?DomainPage $page): static
|
||||
{
|
||||
$this->page = $page;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user