Person.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace Tree\Fixture\Closure;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @Gedmo\Tree(type="closure")
  7. * @Gedmo\TreeClosure(class="Tree\Fixture\Closure\PersonClosure")
  8. * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\ClosureTreeRepository")
  9. * @ORM\InheritanceType("JOINED")
  10. * @ORM\DiscriminatorColumn(name="discriminator", type="string")
  11. * @ORM\DiscriminatorMap({
  12. "user" = "User"
  13. })
  14. */
  15. class Person
  16. {
  17. /**
  18. * @ORM\Column(name="id", type="integer")
  19. * @ORM\Id
  20. * @ORM\GeneratedValue
  21. */
  22. private $id;
  23. /**
  24. * @ORM\Column(name="full_name", type="string", length=64)
  25. */
  26. private $fullName;
  27. /**
  28. * @Gedmo\TreeParent
  29. * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
  30. * @ORM\ManyToOne(targetEntity="Person", inversedBy="children", cascade={"persist"})
  31. */
  32. private $parent;
  33. /**
  34. * @ORM\Column(name="level", type="integer")
  35. * @Gedmo\TreeLevel
  36. */
  37. private $level;
  38. public function getId()
  39. {
  40. return $this->id;
  41. }
  42. public function setName($name)
  43. {
  44. $this->name = $name;
  45. }
  46. public function getName()
  47. {
  48. return $this->name;
  49. }
  50. public function setParent(Category $parent = null)
  51. {
  52. $this->parent = $parent;
  53. }
  54. public function getParent()
  55. {
  56. return $this->parent;
  57. }
  58. public function addClosure(CategoryClosure $closure)
  59. {
  60. $this->closures[] = $closure;
  61. }
  62. public function setLevel($level)
  63. {
  64. $this->level = $level;
  65. }
  66. public function getLevel()
  67. {
  68. return $this->level;
  69. }
  70. public function setFullName($fullName)
  71. {
  72. $this->fullName = $fullName;
  73. }
  74. public function getFullName()
  75. {
  76. return $this->fullName;
  77. }
  78. }