TreeSlug.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Sluggable\Fixture\Document;
  3. use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. /**
  6. * @ODM\Document
  7. */
  8. class TreeSlug
  9. {
  10. /**
  11. * @ODM\Id
  12. */
  13. private $id;
  14. /**
  15. * @ODM\String
  16. */
  17. private $title;
  18. /**
  19. * @Gedmo\Slug(handlers={
  20. * @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\TreeSlugHandler", options={
  21. * @Gedmo\SlugHandlerOption(name="parentRelationField", value="parent"),
  22. * @Gedmo\SlugHandlerOption(name="separator", value="/")
  23. * })
  24. * }, separator="-", updatable=true, fields={"title"})
  25. * @ODM\String
  26. */
  27. private $alias;
  28. /**
  29. * @ODM\ReferenceOne(targetDocument="TreeSlug")
  30. */
  31. private $parent;
  32. public function setParent(TreeSlug $parent = null)
  33. {
  34. $this->parent = $parent;
  35. }
  36. public function getParent()
  37. {
  38. return $this->parent;
  39. }
  40. public function getId()
  41. {
  42. return $this->id;
  43. }
  44. public function setTitle($title)
  45. {
  46. $this->title = $title;
  47. }
  48. public function getTitle()
  49. {
  50. return $this->title;
  51. }
  52. public function getSlug()
  53. {
  54. return $this->alias;
  55. }
  56. }