Category.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Tree\Fixture\Closure;
  3. /**
  4. * @Entity
  5. * @gedmo:Tree(type="closure")
  6. * @gedmo:TreeClosure(class="Tree\Fixture\Closure\CategoryClosure")
  7. */
  8. class Category
  9. {
  10. /**
  11. * @Column(name="id", type="integer")
  12. * @Id
  13. * @GeneratedValue
  14. */
  15. private $id;
  16. /**
  17. * @Column(name="title", type="string", length=64)
  18. */
  19. private $title;
  20. /**
  21. * @gedmo:TreeParent
  22. * @JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
  23. * @ManyToOne(targetEntity="Category", inversedBy="children", cascade={"persist"})
  24. */
  25. private $parent;
  26. /**
  27. * @OneToMany(targetEntity="Category", mappedBy="parent", cascade={"persist"})
  28. */
  29. private $children;
  30. /**
  31. * @gedmo:TreeChildCount
  32. * @Column(type="integer", nullable="true")
  33. */
  34. private $childCount;
  35. public function getId()
  36. {
  37. return $this->id;
  38. }
  39. public function setTitle($title)
  40. {
  41. $this->title = $title;
  42. }
  43. public function getTitle()
  44. {
  45. return $this->title;
  46. }
  47. public function setParent(Category $parent)
  48. {
  49. $this->parent = $parent;
  50. }
  51. public function getParent()
  52. {
  53. return $this->parent;
  54. }
  55. public function getChildCount()
  56. {
  57. return $this->childCount;
  58. }
  59. }