2016-03-23 22:01:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Entity\Blogs;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
|
|
|
/**
|
2016-12-11 03:03:59 +00:00
|
|
|
* @ORM\Table(name="posts_tags", schema="posts")
|
2016-03-23 22:01:18 +00:00
|
|
|
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostTagRepository")
|
|
|
|
*/
|
|
|
|
class PostTag
|
|
|
|
{
|
|
|
|
/**
|
2017-01-12 22:58:52 +00:00
|
|
|
* @var int
|
2016-03-23 22:01:18 +00:00
|
|
|
*
|
|
|
|
* @ORM\Column(name="id", type="integer")
|
|
|
|
* @ORM\Id
|
|
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Post
|
|
|
|
*
|
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post", inversedBy="postTags")
|
|
|
|
* @ORM\JoinColumn(name="post_id", onDelete="CASCADE")
|
|
|
|
*/
|
|
|
|
private $post;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Tag
|
|
|
|
*
|
2017-01-12 22:58:52 +00:00
|
|
|
* @todo fix SET NULL
|
|
|
|
*
|
2016-03-23 22:01:18 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Tag", fetch="EAGER")
|
|
|
|
* @ORM\JoinColumn(name="tag_id", onDelete="SET NULL")
|
|
|
|
*/
|
|
|
|
private $tag;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*
|
2016-03-26 21:33:55 +00:00
|
|
|
* @ORM\Column(name="text", type="text")
|
2016-03-23 22:01:18 +00:00
|
|
|
*/
|
|
|
|
private $text;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(Tag $tag)
|
|
|
|
{
|
|
|
|
$this->tag = $tag;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getId(): int
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setText(string $text): self
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
$this->text = $text;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getText(): string
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
return $this->text;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getOriginalTagText(): string
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
return $this->tag ? $this->tag->getText() : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set post
|
|
|
|
*
|
2017-01-12 22:58:52 +00:00
|
|
|
* @todo move to constructor
|
|
|
|
*
|
2016-03-23 22:01:18 +00:00
|
|
|
* @param Post $post
|
|
|
|
* @return PostTag
|
|
|
|
*/
|
2017-01-12 22:58:52 +00:00
|
|
|
public function setPost(Post $post = null): self
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
$this->post = $post;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getPost(): Post
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
return $this->post;
|
|
|
|
}
|
|
|
|
|
2017-01-12 22:58:52 +00:00
|
|
|
public function getTag(): Tag
|
2016-03-23 22:01:18 +00:00
|
|
|
{
|
|
|
|
return $this->tag;
|
|
|
|
}
|
|
|
|
}
|