Added the Taggable interface to blog posts

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI (W00d5t0ck)
2012-09-16 22:58:51 +02:00
parent 831f4ca317
commit 507a8a5721
7 changed files with 131 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ use Gedmo\Mapping\Annotation as GedmoORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use DoctrineExtensions\Taggable\Taggable;
use GergelyPolonkai\FrontBundle\Entity\Comment;
use GergelyPolonkai\FrontBundle\Entity\User;
@@ -19,7 +20,7 @@ use GergelyPolonkai\FrontBundle\Entity\User;
* @ORM\Entity
* @ORM\Table(name="blog_posts")
*/
class Post
class Post implements Taggable
{
/**
* @var integer $id
@@ -86,6 +87,8 @@ class Post
*/
private $comments;
private $tags;
/**
* Constructor
*/
@@ -273,4 +276,21 @@ class Post
{
return $this->comments;
}
public function getTags()
{
$this->tags = $this->tags ?: new ArrayCollection();
return $this->tags;
}
public function getTaggableType()
{
return 'gergelypolonkaifront_post';
}
public function getTaggableId()
{
return $this->id;
}
}