MPCategory.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace Tree\Fixture;
  3. use Gedmo\Tree\Node as NodeInterface;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\MaterializedPathRepository")
  8. * @Gedmo\Tree(type="materializedPath")
  9. */
  10. class MPCategory
  11. {
  12. /**
  13. * @ORM\Column(name="id", type="integer")
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. */
  17. private $id;
  18. /**
  19. * @Gedmo\TreePath
  20. * @ORM\Column(name="path", type="string", length=3000, nullable=true)
  21. */
  22. private $path;
  23. /**
  24. * @Gedmo\TreePathSource
  25. * @ORM\Column(name="title", type="string", length=64)
  26. */
  27. private $title;
  28. /**
  29. * @Gedmo\TreeParent
  30. * @ORM\ManyToOne(targetEntity="MPCategory", inversedBy="children")
  31. * @ORM\JoinColumns({
  32. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
  33. * })
  34. */
  35. private $parentId;
  36. /**
  37. * @Gedmo\TreeLevel
  38. * @ORM\Column(name="lvl", type="integer", nullable=true)
  39. */
  40. private $level;
  41. /**
  42. * @ORM\OneToMany(targetEntity="MPCategory", mappedBy="parent")
  43. */
  44. private $children;
  45. /**
  46. * @ORM\OneToMany(targetEntity="Article", mappedBy="category")
  47. */
  48. private $comments;
  49. public function getId()
  50. {
  51. return $this->id;
  52. }
  53. public function setTitle($title)
  54. {
  55. $this->title = $title;
  56. }
  57. public function getTitle()
  58. {
  59. return $this->title;
  60. }
  61. public function setParent(MPCategory $parent = null)
  62. {
  63. $this->parentId = $parent;
  64. }
  65. public function getParent()
  66. {
  67. return $this->parentId;
  68. }
  69. public function setPath($path)
  70. {
  71. $this->path = $path;
  72. }
  73. public function getPath()
  74. {
  75. return $this->path;
  76. }
  77. public function getLevel()
  78. {
  79. return $this->level;
  80. }
  81. }