RelativeSlug.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 RelativeSlug
  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\RelativeSlugHandler", options={
  21. * @Gedmo\SlugHandlerOption(name="relationField", value="article"),
  22. * @Gedmo\SlugHandlerOption(name="relationSlugField", value="slug"),
  23. * @Gedmo\SlugHandlerOption(name="separator", value="/")
  24. * })
  25. * }, separator="-", updatable=true, fields={"title"})
  26. * @ODM\String
  27. */
  28. private $alias;
  29. /**
  30. * @ODM\ReferenceOne(targetDocument="Article")
  31. */
  32. private $article;
  33. public function setArticle(Article $article = null)
  34. {
  35. $this->article = $article;
  36. }
  37. public function getArticle()
  38. {
  39. return $this->article;
  40. }
  41. public function getId()
  42. {
  43. return $this->id;
  44. }
  45. public function setTitle($title)
  46. {
  47. $this->title = $title;
  48. }
  49. public function getTitle()
  50. {
  51. return $this->title;
  52. }
  53. public function getSlug()
  54. {
  55. return $this->alias;
  56. }
  57. }