TreeSlug.php 2.3 KB

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