V-Beta-1.0.0
Vision is out of alpha !
This commit is contained in:
124
src/Entity/Comment.php
Normal file
124
src/Entity/Comment.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Repository\CommentRepository;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=CommentRepository::class)
|
||||
* @Gedmo\Loggable
|
||||
*/
|
||||
class Comment
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @Gedmo\Versioned
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user