TreeSlug.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. * @Gedmo\Sluggable
  19. * @ORM\Column(name="title", type="string", length=64)
  20. */
  21. private $title;
  22. /**
  23. * @Gedmo\Slug(handlers={
  24. * @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\TreeSlugHandler", options={
  25. * @Gedmo\SlugHandlerOption(name="parentRelation", value="parent"),
  26. * @Gedmo\SlugHandlerOption(name="targetField", value="title"),
  27. * @Gedmo\SlugHandlerOption(name="separator", value="/")
  28. * })
  29. * }, separator="-", updatable=true)
  30. * @ORM\Column(name="slug", type="string", length=64, unique=true)
  31. */
  32. private $slug;
  33. /**
  34. * @Gedmo\TreeParent
  35. * @ORM\ManyToOne(targetEntity="TreeSlug")
  36. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
  37. */
  38. private $parent;
  39. /**
  40. * @Gedmo\TreeLeft
  41. * @ORM\Column(type="integer")
  42. */
  43. private $lft;
  44. /**
  45. * @Gedmo\TreeRight
  46. * @ORM\Column(type="integer")
  47. */
  48. private $rgt;
  49. /**
  50. * @Gedmo\TreeRoot
  51. * @ORM\Column(type="integer")
  52. */
  53. private $root;
  54. /**
  55. * @Gedmo\TreeLevel
  56. * @ORM\Column(name="lvl", type="integer")
  57. */
  58. private $level;
  59. public function setParent(TreeSlug $parent = null)
  60. {
  61. $this->parent = $parent;
  62. }
  63. public function getChildren()
  64. {
  65. return $this->children;
  66. }
  67. public function getParent()
  68. {
  69. return $this->parent;
  70. }
  71. public function getRoot()
  72. {
  73. return $this->root;
  74. }
  75. public function getLeft()
  76. {
  77. return $this->lft;
  78. }
  79. public function getRight()
  80. {
  81. return $this->rgt;
  82. }
  83. public function getLevel()
  84. {
  85. return $this->level;
  86. }
  87. public function getId()
  88. {
  89. return $this->id;
  90. }
  91. public function setTitle($title)
  92. {
  93. $this->title = $title;
  94. }
  95. public function getTitle()
  96. {
  97. return $this->title;
  98. }
  99. public function getSlug()
  100. {
  101. return $this->slug;
  102. }
  103. }