Basic implementation of blogs (posts, comments, tags). No migration yet.

This commit is contained in:
Alexey Skobkin 2015-06-01 03:39:14 +03:00
parent 76d75542fd
commit 42b213ac85
3 changed files with 549 additions and 0 deletions

View File

@ -0,0 +1,234 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
use Doctrine\ORM\Mapping as ORM;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
/**
* Comment
*
* @ORM\Table(name="posts.comments")
* @ORM\Entity
*/
class Comment
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="text", type="text")
*/
private $text;
/**
* @var \DateTime
*
* @ORM\Column(name="createdAt", type="datetime")
*/
private $createdAt;
/**
* @var boolean
*
* @ORM\Column(name="isRec", type="boolean")
*/
private $isRec;
/**
* @var int
*
* @ORM\Column(name="number", type="integer")
*/
private $number;
/**
* @var Post
*
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post")
* @ORM\JoinColumn(name="post_id")
*/
private $post;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\User")
* @ORM\JoinColumn(name="author_id")
*/
private $author;
/**
* @var Comment
*
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment")
* @ORM\JoinColumn(name="to_comment_id", nullable=true)
*/
private $toComment;
/**
* 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
*
* @param boolean $isRec
* @return Comment
*/
public function setIsRec($isRec)
{
$this->isRec = $isRec;
return $this;
}
/**
* Get isRec
*
* @return boolean
*/
public function isRec()
{
return $this->isRec;
}
/**
* @return int
*/
public function getNumber()
{
return $this->number;
}
/**
* @param int $number
* @return Comment
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}
/**
* @return Post
*/
public function getPost()
{
return $this->post;
}
/**
* @param Post $post
* @return Comment
*/
public function setPost($post)
{
$this->post = $post;
return $this;
}
/**
* @return User
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param User $author
* @return Comment
*/
public function setAuthor($author)
{
$this->author = $author;
return $this;
}
/**
* @return Comment
*/
public function getToComment()
{
return $this->toComment;
}
/**
* @param Comment $toComment
* @return Comment
*/
public function setToComment($toComment)
{
$this->toComment = $toComment;
return $this;
}
}

View File

@ -0,0 +1,251 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
/**
* Post
*
* @ORM\Table(name="posts.posts")
* @ORM\Entity
*/
class Post
{
/**
* @var integer
*
* @ORM\Column(name="id", type="string", length=16)
* @ORM\Id
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="uid", type="integer")
*/
private $uid;
/**
* @var string
*
* @ORM\Column(name="text", type="text")
*/
private $text;
/**
* @var \DateTime
*
* @ORM\Column(name="createdAt", type="datetime")
*/
private $createdAt;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=6)
*/
private $type;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\User")
* @ORM\JoinColumn(name="author")
*/
private $author;
/**
* @var Tag[]|Collection
*
* @ORM\ManyToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Tag", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="posts.posts_tags",
* joinColumns={@ORM\JoinColumn(name="post_id")},
* inverseJoinColumns={@ORM\JoinColumn(name="tag_id")}
* )
*/
private $tags;
/**
* @var Comment[]|Collection
*/
private $comments;
public function __construct()
{
$this->tags = new ArrayCollection();
$this->comments = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set uid
*
* @param integer $uid
* @return Post
*/
public function setUid($uid)
{
$this->uid = $uid;
return $this;
}
/**
* Get uid
*
* @return integer
*/
public function getUid()
{
return $this->uid;
}
/**
* Set text
*
* @param string $text
* @return Post
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
* @return Post
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set type
*
* @param string $type
* @return Post
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return User
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param User $author
* @return Post
*/
public function setAuthor($author)
{
$this->author = $author;
return $this;
}
/**
* Set id
*
* @param string $id
* @return Post
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Add tags
*
* @param Tag $tags
* @return Post
*/
public function addTag(Tag $tags)
{
$this->tags[] = $tags;
return $this;
}
/**
* Remove tags
*
* @param Tag $tags
*/
public function removeTag(Tag $tags)
{
$this->tags->removeElement($tags);
}
/**
* Get tags
*
* @return Collection
*/
public function getTags()
{
return $this->tags;
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
use Doctrine\ORM\Mapping as ORM;
/**
* Tag
*
* @ORM\Table(name="posts.tags")
* @ORM\Entity
*/
class Tag
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="text", type="string", length=128, unique=true)
*/
private $text;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set text
*
* @param string $text
* @return Tag
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
{
return $this->text;
}
}