130 lines
2.6 KiB
PHP
130 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use App\Repository\CommentRepository;
|
|
use Gedmo\Mapping\Annotation as Gedmo;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
/**
|
|
* @ORM\Entity(repositoryClass=CommentRepository::class)
|
|
* @Gedmo\Loggable
|
|
*/
|
|
class Comment
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="text", length=65535)
|
|
* @Gedmo\Versioned
|
|
* @Assert\Length(
|
|
* max=65535,
|
|
* maxMessage="Content too long : {{ limit }} max"
|
|
* )
|
|
*/
|
|
private $content;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=Document::class, inversedBy="comments")
|
|
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
|
|
*/
|
|
private $document;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime_immutable")
|
|
* @Gedmo\Timestampable(on="create")
|
|
*/
|
|
private $createdAt;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="comments")
|
|
* @ORM\JoinColumn(nullable=false)
|
|
*/
|
|
private $creator;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=Group::class, inversedBy="comments")
|
|
* @ORM\JoinColumn(nullable=false)
|
|
*/
|
|
private $mainGroup;
|
|
|
|
public function __construct(User $user = null)
|
|
{
|
|
if ($user != null) {
|
|
$this->setCreator($user);
|
|
$this->setMainGroup($user->getMainGroup());
|
|
}
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getContent(): ?string
|
|
{
|
|
return $this->content;
|
|
}
|
|
|
|
public function setContent(string $content): self
|
|
{
|
|
$this->content = $content;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDocument(): ?Document
|
|
{
|
|
return $this->document;
|
|
}
|
|
|
|
public function setDocument(?Document $document): self
|
|
{
|
|
$this->document = $document;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function setCreatedAt(\DateTimeImmutable $createdAt): self
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreator(): ?User
|
|
{
|
|
return $this->creator;
|
|
}
|
|
|
|
public function setCreator(?User $creator): self
|
|
{
|
|
$this->creator = $creator;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getMainGroup(): ?Group
|
|
{
|
|
return $this->mainGroup;
|
|
}
|
|
|
|
public function setMainGroup(?Group $mainGroup): self
|
|
{
|
|
$this->mainGroup = $mainGroup;
|
|
|
|
return $this;
|
|
}
|
|
}
|