2015-06-01 00:39:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
|
|
|
|
|
2016-03-23 22:01:18 +00:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
2015-06-01 00:39:14 +00:00
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use Skobkin\Bundle\PointToolsBundle\Entity\User;
|
|
|
|
|
|
|
|
/**
|
2016-12-11 03:03:59 +00:00
|
|
|
* @ORM\Table(name="comments", schema="posts", indexes={
|
2015-10-26 02:57:53 +00:00
|
|
|
* @ORM\Index(name="idx_comment_created_at", columns={"created_at"})
|
|
|
|
* })
|
2017-01-11 16:11:55 +00:00
|
|
|
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository")
|
2015-06-01 00:39:14 +00:00
|
|
|
*/
|
|
|
|
class Comment
|
|
|
|
{
|
|
|
|
/**
|
2016-03-23 22:01:18 +00:00
|
|
|
* @var int
|
2015-06-01 00:39:14 +00:00
|
|
|
*
|
|
|
|
* @ORM\Column(name="id", type="integer")
|
|
|
|
* @ORM\Id
|
2016-03-23 22:01:18 +00:00
|
|
|
* @ORM\GeneratedValue
|
2015-06-01 00:39:14 +00:00
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*
|
|
|
|
* @ORM\Column(name="text", type="text")
|
|
|
|
*/
|
|
|
|
private $text;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \DateTime
|
|
|
|
*
|
2015-10-26 02:57:53 +00:00
|
|
|
* @ORM\Column(name="created_at", type="datetime")
|
2015-06-01 00:39:14 +00:00
|
|
|
*/
|
|
|
|
private $createdAt;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var boolean
|
|
|
|
*
|
2015-10-26 02:57:53 +00:00
|
|
|
* @ORM\Column(name="is_rec", type="boolean")
|
2015-06-01 00:39:14 +00:00
|
|
|
*/
|
2015-10-26 02:57:53 +00:00
|
|
|
private $rec;
|
2015-06-01 00:39:14 +00:00
|
|
|
|
|
|
|
/**
|
2015-10-26 02:57:53 +00:00
|
|
|
* @var bool
|
2015-06-01 00:39:14 +00:00
|
|
|
*
|
2015-10-26 02:57:53 +00:00
|
|
|
* @ORM\Column(name="is_deleted", type="boolean")
|
2015-06-01 00:39:14 +00:00
|
|
|
*/
|
2015-10-26 02:57:53 +00:00
|
|
|
private $deleted = false;
|
2015-06-01 00:39:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Post
|
|
|
|
*
|
2016-03-16 20:08:48 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post", inversedBy="comments")
|
2015-06-01 00:39:14 +00:00
|
|
|
* @ORM\JoinColumn(name="post_id")
|
|
|
|
*/
|
|
|
|
private $post;
|
|
|
|
|
2016-03-23 22:01:18 +00:00
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*
|
|
|
|
* @ORM\Column(name="number", type="smallint")
|
|
|
|
*/
|
|
|
|
private $number;
|
|
|
|
|
2015-06-01 00:39:14 +00:00
|
|
|
/**
|
|
|
|
* @var User
|
|
|
|
*
|
2016-03-23 22:01:18 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\User", fetch="EAGER")
|
2015-06-01 00:39:14 +00:00
|
|
|
* @ORM\JoinColumn(name="author_id")
|
|
|
|
*/
|
|
|
|
private $author;
|
|
|
|
|
2016-03-24 21:28:43 +00:00
|
|
|
/**
|
|
|
|
* @var File[]|ArrayCollection
|
|
|
|
*
|
|
|
|
* @ORM\ManyToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\File", fetch="EXTRA_LAZY", cascade={"persist"})
|
2016-12-11 03:03:59 +00:00
|
|
|
* @ORM\JoinTable(name="comments_files", schema="posts",
|
2016-03-24 21:28:43 +00:00
|
|
|
* joinColumns={@ORM\JoinColumn(name="comment_id")},
|
|
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="file_id")}
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
private $files;
|
|
|
|
|
2015-06-01 00:39:14 +00:00
|
|
|
/**
|
2015-10-26 02:57:53 +00:00
|
|
|
* @var Comment|null
|
2015-06-01 00:39:14 +00:00
|
|
|
*
|
2016-03-23 22:01:18 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment", inversedBy="children")
|
|
|
|
* @ORM\JoinColumn(name="parent_id", nullable=true)
|
2015-06-01 00:39:14 +00:00
|
|
|
*/
|
2016-03-23 22:01:18 +00:00
|
|
|
private $parent;
|
2015-06-01 00:39:14 +00:00
|
|
|
|
2015-10-26 02:57:53 +00:00
|
|
|
/**
|
2016-12-12 18:02:19 +00:00
|
|
|
* @var Comment[]|ArrayCollection
|
2016-03-23 22:01:18 +00:00
|
|
|
*
|
|
|
|
* @ORM\OneToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment", fetch="EXTRA_LAZY", mappedBy="parent")
|
2015-10-26 02:57:53 +00:00
|
|
|
*/
|
2016-03-23 22:01:18 +00:00
|
|
|
private $children;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
2015-10-26 02:57:53 +00:00
|
|
|
{
|
2016-03-24 21:28:43 +00:00
|
|
|
$this->files = new ArrayCollection();
|
2016-03-23 22:01:18 +00:00
|
|
|
$this->children = new ArrayCollection();
|
2015-10-26 02:57:53 +00:00
|
|
|
}
|
2015-06-01 00:39:14 +00:00
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getId(): int
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setCreatedAt(\DateTime $createdAt): self
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
$this->createdAt = $createdAt;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getCreatedAt(): \DateTime
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
return $this->createdAt;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setText(string $text): self
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
$this->text = $text;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getText(): string
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
return $this->text;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setRec(bool $rec): self
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
2015-10-26 02:57:53 +00:00
|
|
|
$this->rec = $rec;
|
2015-06-01 00:39:14 +00:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function isRec(): bool
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
2015-10-26 02:57:53 +00:00
|
|
|
return $this->rec;
|
2015-06-01 00:39:14 +00:00
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getRec(): bool
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
2015-10-26 02:57:53 +00:00
|
|
|
return $this->rec;
|
2015-06-01 00:39:14 +00:00
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getPost(): Post
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
return $this->post;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setPost(Post $post): self
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
$this->post = $post;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setNumber(int $number): self
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
$this->number = $number;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getNumber(): int
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
return $this->number;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getAuthor(): User
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
return $this->author;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setAuthor(User $author): self
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
|
|
|
$this->author = $author;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function addFile(File $files): self
|
2016-03-24 21:28:43 +00:00
|
|
|
{
|
|
|
|
$this->files[] = $files;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function removeFile(File $files): void
|
2016-03-24 21:28:43 +00:00
|
|
|
{
|
|
|
|
$this->files->removeElement($files);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return File[]|ArrayCollection
|
|
|
|
*/
|
2017-01-12 23:38:33 +00:00
|
|
|
public function getFiles(): iterable
|
2016-03-24 21:28:43 +00:00
|
|
|
{
|
|
|
|
return $this->files;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getParent(): ?Comment
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
2016-03-23 22:01:18 +00:00
|
|
|
return $this->parent;
|
2015-06-01 00:39:14 +00:00
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setParent(Comment $parent): self
|
2015-06-01 00:39:14 +00:00
|
|
|
{
|
2016-03-23 22:01:18 +00:00
|
|
|
$this->parent = $parent;
|
2015-06-01 00:39:14 +00:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setDeleted(bool $deleted): self
|
2015-10-26 02:57:53 +00:00
|
|
|
{
|
|
|
|
$this->deleted = $deleted;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getDeleted(): bool
|
2015-10-26 02:57:53 +00:00
|
|
|
{
|
|
|
|
return $this->deleted;
|
|
|
|
}
|
2015-06-01 00:39:14 +00:00
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function isDeleted(): bool
|
2015-10-26 02:57:53 +00:00
|
|
|
{
|
|
|
|
return $this->deleted;
|
|
|
|
}
|
2016-03-23 22:01:18 +00:00
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function addChild(Comment $children): self
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
$this->children[] = $children;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function removeChild(Comment $children): void
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
$this->children->removeElement($children);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-12 18:02:19 +00:00
|
|
|
* @return Comment[]|ArrayCollection
|
2016-03-23 22:01:18 +00:00
|
|
|
*/
|
2017-01-12 23:38:33 +00:00
|
|
|
public function getChildren(): iterable
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
return $this->children;
|
|
|
|
}
|
2015-06-01 00:39:14 +00:00
|
|
|
}
|