Sluggable.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace Mapping\Fixture;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity
  7. */
  8. class Sluggable
  9. {
  10. /**
  11. * @ORM\Id
  12. * @ORM\GeneratedValue
  13. * @ORM\Column(type="integer")
  14. */
  15. private $id;
  16. /**
  17. * @ORM\Column(name="title", type="string", length=64)
  18. */
  19. private $title;
  20. /**
  21. * @ORM\Column(name="code", type="string", length=16)
  22. */
  23. private $code;
  24. /**
  25. * @Gedmo\Slug(handlers={
  26. * @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\TreeSlugHandler", options={
  27. * @Gedmo\SlugHandlerOption(name="parentRelationField", value="parent"),
  28. * @Gedmo\SlugHandlerOption(name="separator", value="/")
  29. * }),
  30. * @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
  31. * @Gedmo\SlugHandlerOption(name="relationField", value="user"),
  32. * @Gedmo\SlugHandlerOption(name="relationSlugField", value="slug"),
  33. * @Gedmo\SlugHandlerOption(name="separator", value="/")
  34. * })
  35. * }, separator="-", updatable=false, fields={"title", "code"})
  36. * @ORM\Column(name="slug", type="string", length=64, unique=true)
  37. */
  38. private $slug;
  39. /**
  40. * @ORM\ManyToOne(targetEntity="Sluggable")
  41. */
  42. private $parent;
  43. /**
  44. * @ORM\ManyToOne(targetEntity="User")
  45. */
  46. private $user;
  47. public function getId()
  48. {
  49. return $this->id;
  50. }
  51. public function setTitle($title)
  52. {
  53. $this->title = $title;
  54. }
  55. public function getTitle()
  56. {
  57. return $this->title;
  58. }
  59. public function setCode($code)
  60. {
  61. $this->code = $code;
  62. }
  63. public function getCode()
  64. {
  65. return $this->code;
  66. }
  67. public function getSlug()
  68. {
  69. return $this->slug;
  70. }
  71. }