Skip to content

Instantly share code, notes, and snippets.

@enricostano
Created May 26, 2012 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enricostano/2795629 to your computer and use it in GitHub Desktop.
Save enricostano/2795629 to your computer and use it in GitHub Desktop.
Term Class
<?php
namespace StanoSas\Bundle\TaxonomyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* StanoSas\Bundle\TaxonomyBundle\Entity\Term
*
* @Gedmo\Tree(type="nested")
* @ORM\Table()
* @ORM\Entity(repositoryClass="StanoSas\Bundle\TaxonomyBundle\Entity\TermRepository")
*/
class Term
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Vocabulary", inversedBy="terms")
*/
private $vocabulary;
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string $slug
*
* @ORM\Column(name="slug", type="string", length=255)
*/
private $slug;
/**
* @Gedmo\TreeLeft
* @ORM\Column(name="lft", type="integer")
*/
private $lft;
/**
* @Gedmo\TreeLevel
* @ORM\Column(name="lvl", type="integer")
*/
private $lvl;
/**
* @Gedmo\TreeRight
* @ORM\Column(name="rgt", type="integer")
*/
private $rgt;
/**
* @Gedmo\TreeRoot
* @ORM\Column(name="root", type="integer", nullable=true)
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="Term", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="Term", mappedBy="parent")
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
public function __construct()
{
$this->children = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set slug
*
* @param string $slug
*/
public function setSlug($slug)
{
$this->slug = $slug;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set parent
*
* @param integer $parent
*/
public function setParent(Term $parent = null)
{
$this->parent = $parent;
}
/**
* Get parent
*
* @return integer
*/
public function getParent()
{
return $this->parent;
}
/**
* Set vocabulary
*
* @param StanoSas\Bundle\TaxonomyBundle\Entity\Vocabulary $vocabulary
*/
public function setVocabulary(\StanoSas\Bundle\TaxonomyBundle\Entity\Vocabulary $vocabulary)
{
$this->vocabulary = $vocabulary;
}
/**
* Get vocabulary
*
* @return StanoSas\Bundle\TaxonomyBundle\Entity\Vocabulary
*/
public function getVocabulary()
{
return $this->vocabulary;
}
/**
* Add children
*
* @param StanoSas\Bundle\TaxonomyBundle\Entity\Term $children
*/
public function addTerm(\StanoSas\Bundle\TaxonomyBundle\Entity\Term $children)
{
$this->children[] = $children;
}
/**
* Get children
*
* @return Doctrine\Common\Collections\Collection
*/
public function getChildren()
{
return $this->children;
}
/**
* Set lft
*
* @param integer $lft
*/
public function setLft($lft)
{
$this->lft = $lft;
}
/**
* Get lft
*
* @return integer
*/
public function getLft()
{
return $this->lft;
}
/**
* Set lvl
*
* @param integer $lvl
*/
public function setLvl($lvl)
{
$this->lvl = $lvl;
}
/**
* Get lvl
*
* @return integer
*/
public function getLvl()
{
return $this->lvl;
}
/**
* Set rgt
*
* @param integer $rgt
*/
public function setRgt($rgt)
{
$this->rgt = $rgt;
}
/**
* Get rgt
*
* @return integer
*/
public function getRgt()
{
return $this->rgt;
}
/**
* Set root
*
* @param integer $root
*/
public function setRoot($root)
{
$this->root = $root;
}
/**
* Get root
*
* @return integer
*/
public function getRoot()
{
return $this->root;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment