TreeSlug.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. * @Gedmo\Sluggable(slugField="alias")
  16. * @ODM\String
  17. */
  18. private $title;
  19. /**
  20. * @Gedmo\Slug(handlers={
  21. * @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\TreeSlugHandler", options={
  22. * @Gedmo\SlugHandlerOption(name="parentRelation", value="parent"),
  23. * @Gedmo\SlugHandlerOption(name="targetField", value="title"),
  24. * @Gedmo\SlugHandlerOption(name="separator", value="/")
  25. * })
  26. * }, separator="-", updatable=true)
  27. * @ODM\String
  28. */
  29. private $alias;
  30. /**
  31. * @ODM\ReferenceOne(targetDocument="TreeSlug")
  32. */
  33. private $parent;
  34. public function setParent(TreeSlug $parent = null)
  35. {
  36. $this->parent = $parent;
  37. }
  38. public function getParent()
  39. {
  40. return $this->parent;
  41. }
  42. public function getId()
  43. {
  44. return $this->id;
  45. }
  46. public function setTitle($title)
  47. {
  48. $this->title = $title;
  49. }
  50. public function getTitle()
  51. {
  52. return $this->title;
  53. }
  54. public function getSlug()
  55. {
  56. return $this->alias;
  57. }
  58. }