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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Comment
|
|
|
|
*
|
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"})
|
|
|
|
* })
|
2015-06-01 00:39:14 +00:00
|
|
|
* @ORM\Entity
|
|
|
|
*/
|
|
|
|
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-03-23 22:01:18 +00:00
|
|
|
* @var Comment[]
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
|
|
|
/**
|
|
|
|
* Get id
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set createdAt
|
|
|
|
*
|
|
|
|
* @param \DateTime $createdAt
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function setCreatedAt($createdAt)
|
|
|
|
{
|
|
|
|
$this->createdAt = $createdAt;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get createdAt
|
|
|
|
*
|
|
|
|
* @return \DateTime
|
|
|
|
*/
|
|
|
|
public function getCreatedAt()
|
|
|
|
{
|
|
|
|
return $this->createdAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set text
|
|
|
|
*
|
|
|
|
* @param string $text
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function setText($text)
|
|
|
|
{
|
|
|
|
$this->text = $text;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get text
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getText()
|
|
|
|
{
|
|
|
|
return $this->text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set isRec
|
|
|
|
*
|
2015-10-26 02:57:53 +00:00
|
|
|
* @param boolean $rec
|
2015-06-01 00:39:14 +00:00
|
|
|
* @return Comment
|
|
|
|
*/
|
2015-10-26 02:57:53 +00:00
|
|
|
public function setRec($rec)
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get isRec
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function isRec()
|
|
|
|
{
|
2015-10-26 02:57:53 +00:00
|
|
|
return $this->rec;
|
2015-06-01 00:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-26 02:57:53 +00:00
|
|
|
* Get isRec
|
|
|
|
*
|
|
|
|
* @return boolean
|
2015-06-01 00:39:14 +00:00
|
|
|
*/
|
2015-10-26 02:57:53 +00:00
|
|
|
public function getRec()
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Post
|
|
|
|
*/
|
|
|
|
public function getPost()
|
|
|
|
{
|
|
|
|
return $this->post;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Post $post
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function setPost($post)
|
|
|
|
{
|
|
|
|
$this->post = $post;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-03-23 22:01:18 +00:00
|
|
|
/**
|
|
|
|
* Set number
|
|
|
|
*
|
|
|
|
* @param int $number
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function setNumber($number)
|
|
|
|
{
|
|
|
|
$this->number = $number;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get number
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getNumber()
|
|
|
|
{
|
|
|
|
return $this->number;
|
|
|
|
}
|
|
|
|
|
2015-06-01 00:39:14 +00:00
|
|
|
/**
|
|
|
|
* @return User
|
|
|
|
*/
|
|
|
|
public function getAuthor()
|
|
|
|
{
|
|
|
|
return $this->author;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param User $author
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function setAuthor($author)
|
|
|
|
{
|
|
|
|
$this->author = $author;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-03-24 21:28:43 +00:00
|
|
|
/**
|
|
|
|
* Add files
|
|
|
|
*
|
|
|
|
* @param File $files
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function addFile(File $files)
|
|
|
|
{
|
|
|
|
$this->files[] = $files;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove files
|
|
|
|
*
|
|
|
|
* @param File $files
|
|
|
|
*/
|
|
|
|
public function removeFile(File $files)
|
|
|
|
{
|
|
|
|
$this->files->removeElement($files);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get files
|
|
|
|
*
|
|
|
|
* @return File[]|ArrayCollection
|
|
|
|
*/
|
|
|
|
public function getFiles()
|
|
|
|
{
|
|
|
|
return $this->files;
|
|
|
|
}
|
|
|
|
|
2015-06-01 00:39:14 +00:00
|
|
|
/**
|
|
|
|
* @return Comment
|
|
|
|
*/
|
2016-03-23 22:01:18 +00:00
|
|
|
public function getParent()
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-23 22:01:18 +00:00
|
|
|
* @param Comment $parent
|
2015-06-01 00:39:14 +00:00
|
|
|
* @return Comment
|
|
|
|
*/
|
2016-03-23 22:01:18 +00:00
|
|
|
public function setParent($parent)
|
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;
|
|
|
|
}
|
|
|
|
|
2015-10-26 02:57:53 +00:00
|
|
|
/**
|
|
|
|
* Set deleted
|
|
|
|
*
|
|
|
|
* @param boolean $deleted
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function setDeleted($deleted)
|
|
|
|
{
|
|
|
|
$this->deleted = $deleted;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get deleted
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function getDeleted()
|
|
|
|
{
|
|
|
|
return $this->deleted;
|
|
|
|
}
|
2015-06-01 00:39:14 +00:00
|
|
|
|
2015-10-26 02:57:53 +00:00
|
|
|
/**
|
|
|
|
* Get deleted
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function isDeleted()
|
|
|
|
{
|
|
|
|
return $this->deleted;
|
|
|
|
}
|
2016-03-23 22:01:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add children
|
|
|
|
*
|
|
|
|
* @param Comment $children
|
|
|
|
* @return Comment
|
|
|
|
*/
|
|
|
|
public function addChild(Comment $children)
|
|
|
|
{
|
|
|
|
$this->children[] = $children;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove children
|
|
|
|
*
|
|
|
|
* @param Comment $children
|
|
|
|
*/
|
|
|
|
public function removeChild(Comment $children)
|
|
|
|
{
|
|
|
|
$this->children->removeElement($children);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get children
|
|
|
|
*
|
|
|
|
* @return ArrayCollection
|
|
|
|
*/
|
|
|
|
public function getChildren()
|
|
|
|
{
|
|
|
|
return $this->children;
|
|
|
|
}
|
2015-06-01 00:39:14 +00:00
|
|
|
}
|