Created
May 17, 2012 09:23
-
-
Save kozog/2717692 to your computer and use it in GitHub Desktop.
category entity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace kp\BloggerBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Doctrine\Common\Collections\Collection; | |
use Sylius\Bundle\CategorizerBundle\Entity\NestedCategory as BaseCategory; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
/** | |
* Blog category. | |
* | |
* @author Paweł Jędrzejewski <[email protected]> | |
* @ORM\Table(name="kp_blogger_category") | |
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository") | |
* @Gedmo\Tree(type="nested") | |
*/ | |
class Category extends BaseCategory | |
{ | |
/** | |
* @var integer $id | |
* | |
* @ORM\Column(name="id", type="integer") | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @Gedmo\TreeRoot | |
* @ORM\Column(name="root", type="integer", nullable=true) | |
*/ | |
protected $root; | |
/** | |
* @Gedmo\TreeParent | |
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children") | |
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL") | |
*/ | |
protected $parent; | |
public function getId() | |
{ | |
return $this->id; | |
} | |
public function setId($id) | |
{ | |
$this->id = $id; | |
} | |
/** | |
* @var Collection | |
* @ORM\ManyToMany(targetEntity="kp\BloggerBundle\Entity\Post") | |
*/ | |
private $posts; | |
/** | |
* Constructor. | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->posts = new ArrayCollection; | |
} | |
/** | |
* Get posts. | |
* | |
* @return Collection | |
*/ | |
public function getPosts() | |
{ | |
return $this->posts; | |
} | |
/** | |
* Set posts. | |
* | |
* @param Collection $posts | |
*/ | |
public function setPosts(Collection $posts) | |
{ | |
$this->posts = $posts; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment