RootCategory.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace Tree\Fixture;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
  7. * @Gedmo\Tree(type="nested")
  8. */
  9. class RootCategory
  10. {
  11. /**
  12. * @ORM\Column(name="id", type="integer")
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(name="title", type="string", length=64)
  19. */
  20. private $title;
  21. /**
  22. * @Gedmo\TreeLeft
  23. * @ORM\Column(name="lft", type="integer")
  24. */
  25. private $lft;
  26. /**
  27. * @Gedmo\TreeRight
  28. * @ORM\Column(name="rgt", type="integer")
  29. */
  30. private $rgt;
  31. /**
  32. * @Gedmo\TreeParent
  33. * @ORM\ManyToOne(targetEntity="RootCategory", inversedBy="children")
  34. * @ORM\JoinColumns({
  35. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
  36. * })
  37. */
  38. private $parent;
  39. /**
  40. * @Gedmo\TreeRoot
  41. * @ORM\Column(type="integer")
  42. */
  43. private $root;
  44. /**
  45. * @Gedmo\TreeLevel
  46. * @ORM\Column(name="lvl", type="integer")
  47. */
  48. private $level;
  49. /**
  50. * @ORM\OneToMany(targetEntity="RootCategory", mappedBy="parent")
  51. */
  52. private $children;
  53. public function getId()
  54. {
  55. return $this->id;
  56. }
  57. public function setTitle($title)
  58. {
  59. $this->title = $title;
  60. }
  61. public function getTitle()
  62. {
  63. return $this->title;
  64. }
  65. public function setParent(RootCategory $parent = null)
  66. {
  67. $this->parent = $parent;
  68. }
  69. public function getParent()
  70. {
  71. return $this->parent;
  72. }
  73. public function getRoot()
  74. {
  75. return $this->root;
  76. }
  77. public function getLeft()
  78. {
  79. return $this->lft;
  80. }
  81. public function getRight()
  82. {
  83. return $this->rgt;
  84. }
  85. public function getLevel()
  86. {
  87. return $this->level;
  88. }
  89. }