Added the Taggable interface to blog posts
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
34
src/GergelyPolonkai/FrontBundle/Entity/Tag.php
Normal file
34
src/GergelyPolonkai/FrontBundle/Entity/Tag.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\FrontBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use FPN\TagBundle\Entity\Tag as BaseTag;
|
||||
|
||||
/**
|
||||
* Description of Tag
|
||||
*
|
||||
* @author polesz
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="tags")
|
||||
*/
|
||||
class Tag extends BaseTag
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $tagging
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Tagging", mappedBy="tag", fetch="EAGER")
|
||||
*/
|
||||
protected $tagging;
|
||||
}
|
36
src/GergelyPolonkai/FrontBundle/Entity/Tagging.php
Normal file
36
src/GergelyPolonkai/FrontBundle/Entity/Tagging.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\FrontBundle\Entity;
|
||||
|
||||
use FPN\TagBundle\Entity\Tagging as BaseTagging;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Description of Tagging
|
||||
*
|
||||
* @author polesz
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="tagging", uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="tagging_idx", columns={"tag_id", "resource_type", "resource_id"})
|
||||
* })
|
||||
*/
|
||||
class Tagging extends BaseTagging
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var integer $id
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var GergelyPolonkai\FrontBundle\Entity\Tag $tag
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Tag")
|
||||
*/
|
||||
protected $tag;
|
||||
}
|
Reference in New Issue
Block a user